Skip to content

One observation per sample: no crash with Scott/FD/Doane bin width rules - #180

Open
FBartos wants to merge 1 commit into
jasp-stats:masterfrom
FBartos:fix/bin-width-small-sample
Open

FBartos wants to merge 1 commit into
jasp-stats:masterfrom
FBartos:fix/bin-width-small-sample

Conversation

@FBartos

@FBartos FBartos commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Cause: .getBinWidth passed the rule name through to hist(), but Scott and
Freedman-Diaconis need sd()/IQR() (NA for one observation) and Doane's
formula divides by a skewness SE that is 0 for two and NaN for one
observation. In addition the "Number of observations per sample" field had
no lower bound, so 0 could be typed.
Effect: one observation per sample (a plausible teaching setup) made the
Central limit theorem, Standard error and Sample variability analyses fail
with a fatal error for these three rules.
Fix: fall back to Sturges' rule when there are fewer observations than the
rule needs (< 2, or < 3 for Doane; the manual number of bins is kept), and
set min: 1 on the three cltSampleSize IntegerFields.

🤖 Generated with Claude Code

Cause: .getBinWidth passed the rule name through to hist(), but Scott and
Freedman-Diaconis need sd()/IQR() (NA for one observation) and Doane's
formula divides by a skewness SE that is 0 for two and NaN for one
observation. In addition the "Number of observations per sample" field had
no lower bound, so 0 could be typed.
Effect: one observation per sample (a plausible teaching setup) made the
Central limit theorem, Standard error and Sample variability analyses fail
with a fatal error for these three rules.
Fix: fall back to Sturges' rule when there are fewer observations than the
rule needs (< 2, or < 3 for Doane; the manual number of bins is kept), and
set min: 1 on the three cltSampleSize IntegerFields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant