anova reports F=inf, p=0 for identical constant groups, where F is 0/0 and scipy returns nan
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Locate the Rust ANOVA one-way implementation containing the ms_within == 0.0 guard and check how it computes the between-group mean square. Add or update ANOVA tests so identical constant groups return nan, nan, while groups with positive between-group variance and zero within-group variance still return inf, 0; then run the relevant Rust test suite and the Python binding examples.
Written by the indexing model from the issue text.
Description
anova reports F = inf, p = 0 for groups that are identical and constant — maximal statistical significance from data with no difference at all.
import rssn
s = rssn.Session()
a = s.compute("anova(list(list(5,5,5),list(5,5,5)))")
a.text # 'list(inf, 0)'
a.reduced # True
a.error # None
a.diagnostic_codes # ()
Both groups have mean 5 and zero within-group spread, so SS_between = 0 and SS_within = 0, and F = 0/0 is undefined — not infinite. Reporting p = 0 says "the means differ with probability 1", the strongest possible rejection, about two samples that are bit-identical.
scipy returns (nan, nan) for the same input (with ConstantInputWarning), and rssn's own checked numeric operator rejects it:
rssn.num_stats_ext_anova_one_way([[5.,5.,5.],[5.,5.,5.]], checked=True)
# RssnError: domain error: anova_one_way
The genuinely infinite case is handled correctly, which shows the two cases are distinguishable and the library just conflates them:
s.compute("anova(list(list(1,1,1),list(2,2,2)))").text # 'list(inf, 0)'
scipy.stats.f_oneway([1,1,1],[2,2,2]) # statistic=inf, pvalue=0.0
There SS_between > 0 and SS_within = 0, so F = inf is right. The bug is the guard if ms_within == 0.0 { return (f64::INFINITY, 0.0) }, which fires before checking whether the between-group variance is also zero.
Same result for [[1,1],[1,1]] and for three identical constant groups.
Expected: nan, nan (or an explicit "undefined" report) when both SS_between and SS_within are zero, and inf, 0 only when SS_between > 0.
rssn 0.3.0, Python binding, Windows x86_64.
- Dominant language
- Rust
- Stars
- 36
- Forks
- 3
- Avg merge
- 18h 51m
- Merged PRs (30d)
- 18
Getting set up
- No Dockerfile or Docker Compose file
- No 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 Apich-Organization/rssn
-
area/geometry good first issue help wanted kind/doc-mismatch severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Apich-Organization/rssn#295 ·
Maintainers usually reply within 1 day
-
area/algebra good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Apich-Organization/rssn#293 ·
Maintainers usually reply within 1 day
-
area/linear-algebra good first issue help wanted kind/wrong-result severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Apich-Organization/rssn#277 ·
Maintainers usually reply within 1 day
-
area/linear-algebra good first issue help wanted kind/doc-mismatch severity/5-trivial
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Apich-Organization/rssn#276 ·
Maintainers usually reply within 1 day
-
area/number-theory good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#269 ·
Maintainers usually reply within 1 day
All issues in Apich-Organization/rssn
Similar issues
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
thisnick/agent-wechat#908 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
FortoGraphy/prism-download-manager#242 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
aws/aws-emulator#727 ·