random_state=0 is ignored by MeanEmbeddingTest and SmoothCFTest
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Locate the MeanEmbeddingTest and SmoothCFTest test entry points and inspect how their public test(...) methods handle random_state. Run the focused regressions described in the issue, including the nonzero-seed control; done means random_state=0 is deterministic for both methods while None remains unseeded.
Written by the indexing model from the issue text.
Description
ELI5
Passing random_state=0 looks like it fixes hyppo's random test points, but zero is treated as “no seed.” The same data can therefore switch from significant to non-significant depending on unrelated NumPy calls made earlier.
Exact failure
With hyppo 0.5.2 and fixed 80×3 samples:
MeanEmbeddingTest(..., random_state=0): p=0.016226 after prior seed 31; p=0.794313 after prior seed 2.SmoothCFTest(..., random_state=0): p=0.027979 after prior seed 6; p=0.997951 after prior seed 8.random_state=1is stable under the same control.
Both seed-zero pairs cross 0.05.
Reproduce
import numpy as np
from hyppo.ksample import MeanEmbeddingTest, SmoothCFTest
rng = np.random.default_rng(0)
x = rng.normal(size=(80, 3))
y = rng.normal(loc=0.18, size=(80, 3))
for cls, prior_seeds in [
(MeanEmbeddingTest, (31, 2)),
(SmoothCFTest, (6, 8)),
]:
for prior_seed in prior_seeds:
np.random.seed(prior_seed)
result = cls(num_randfreq=5).test(x, y, random_state=0)
print(cls.__name__, prior_seed, result.stat, result.pvalue)
Full baseline/fixed outputs, tests, patch and hashes are preserved in Cheerful Duck commit 358cc0e. Evidence archive SHA-256: 643181d679db2b238d99eaf913304f1bd61bf600bfb53c096e678196e18d4725.
Fix
Both methods use if random_state:, so integer zero skips np.random.seed(0).
- if random_state:
+ if random_state is not None:
np.random.seed(random_state)
This keeps nonzero seeds unchanged, leaves None unseeded, and makes zero deterministic. Four focused regressions pass across both public test(...) paths and the nonzero-seed control.
Pinned environment
- hyppo 0.5.2, tag commit
2e4a8569b6cd56ffa85f2ac26dc35478af1f7ba9 - current main checked at
a3a2ac323c34b7c98adbf8486bf112afc82f6705 - Python 3.12.14; NumPy 2.5.3; SciPy 1.18.1; scikit-learn 1.9.1
- wheel SHA-256:
5cc18f9e158fe2cf1804c9a1e979e807118ee89a303f29dc5cb8891d92d44ef3
Limits
This demonstrates an inference and reproducibility defect for callers that explicitly use seed zero. I have not established that a specific publication used seed zero or that any published conclusion changes.
- Dominant language
- Python
- Stars
- 253
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from neurodata/hyppo
-
Reusing Dcorr fails after a previous test callPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Great Repository!Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
-
question
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
jira: an unquoted JQL number of more than 4300 digits is a plain-text 500, where real answers 200Openfidelity
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A JSON chat answer blocks the backend event loop for the whole RAG runPossibly taken @NopeCharon claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
The-OpenROAD-Project/ORAssistant#656 ·
Maintainers usually reply within 1 day
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day