hypothesis_test
Classical tests on small data sets: one-sample, paired and two-sample t (Student and Welch), one-way ANOVA, chi-square goodness of fit and independence, or a plain p-value from a t, z, chi-square or F statistic. Gives the statistic, degrees of freedom, exact p-value (own incomplete beta and gamma functions), critical value, effect size and confidence interval.
- Field
- Measurement and data
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001Cauchy closed form: t with 1 df, two-sided p(t = 1) = 1 - (2/pi) atan(1) = 0.5, tails 1/4 and 3/4passed
p_value0.5 ± 5e-070.5lockedunder 0.01 % of the tolerance usedp_upper0.25 ± 2.5e-070.25lockedunder 0.01 % of the tolerance usedp_lower0.75 ± 7.5e-070.75lockedunder 0.01 % of the tolerance usedr0002Cauchy closed form: t with 1 df, upper tail of t = sqrt(3) is 1/2 - atan(sqrt 3)/pi = 1/6passed
p_value0.166667 ± 1.7e-070.166667lockedunder 0.01 % of the tolerance usedr0003t with 2 df closed form p = 1 - t/sqrt(t^2+2): p(4.302652729749464) = 0.05, and the 5 % critical value is sqrt(2*0.9025/0.0975) (textbook 4.3027)passed
p_value0.05 ± 5e-080.05lockedunder 0.01 % of the tolerance usedcritical_value4.30265 ± 4.3e-064.30265lockedunder 0.01 % of the tolerance usedr0004chi-square with 2 df closed form p = exp(-x/2): p(-2 ln 0.05 = 5.9915) = 0.05, critical value 5.991464547107982passed
p_value0.05 ± 5e-080.05lockedunder 0.01 % of the tolerance usedcritical_value5.99146 ± 6e-065.99146lockedunder 0.01 % of the tolerance usedr0005chi-square with 2 df closed form p = exp(-x/2) deep in the tail: p(40) = exp(-20)passed
p_value2.06115e-09 ± 2.1e-152.06115e-09lockedunder 0.01 % of the tolerance usedr0006F(1, 2) = t(2)^2: F = 18.51282051282051 (= 4.3027^2) gives p = 0.05 and is its own 5 % critical valuepassed
p_value0.05 ± 5e-080.05lockedunder 0.01 % of the tolerance usedcritical_value18.5128 ± 1.9e-0518.5128lockedunder 0.01 % of the tolerance usedr0007normal: two-sided p(z = 1.96) = erfc(1.96/sqrt 2) = 0.04999579029644086; 5 % critical value is the textbook 1.959963984540054passed
p_value0.0499958 ± 5e-080.0499958lockedunder 0.01 % of the tolerance usedcritical_value1.95996 ± 2e-061.95996lockedunder 0.01 % of the tolerance usedr0008large df limit: t with 1e6 df, p(1.96) tends to the normal 0.0499958; tolerance 1e-6 absolute because the t-to-normal gap is of order 1/df (about 3e-7 here)passed
p_value0.0499958 ± 1e-060.0499961locked28 % of the tolerance usedr0009Student pooled t by hand, [1,2,3] vs [4,5,6]: t = -3/sqrt(2/3), df 4, p from the 4-df closed form 1 - x(1 + (1-x^2)/2) with x = t/sqrt(t^2+4), d = -3, Hedges g = -3 sqrt(2/pi)passed
statistic-3.67423 ± 3.7e-06-3.67423lockedunder 0.01 % of the tolerance useddf4 ± 4e-064lockedunder 0.01 % of the tolerance usedp_value0.0213116 ± 2.1e-080.0213116lockedunder 0.01 % of the tolerance usedcohen_d-3 ± 3e-06-3lockedunder 0.01 % of the tolerance usedhedges_g-2.39365 ± 2.4e-06-2.39365lockedunder 0.01 % of the tolerance usedestimate-3 ± 3e-06-3lockedunder 0.01 % of the tolerance usedpooled_sd1 ± 1e-061lockedunder 0.01 % of the tolerance usedreject_null= truetruelockedexact matchr0010identical group means: Welch t on [1,2,3] vs [3,2,1] gives t = 0, p = 1, df 4 (equal variances and sizes)passed
statistic0 ± 1e-120lockedunder 0.01 % of the tolerance usedp_value1 ± 1e-121lockedunder 0.01 % of the tolerance useddf4 ± 4e-064lockedunder 0.01 % of the tolerance usedreject_null= falsefalselockedexact matchr0011one-sample t by hand, [5,7,9] against mu0 = 5: t = sqrt 3, df 2, p = 1 - sqrt(3/5), 95 % interval 7 +- 4.3027*2/sqrt 3, d = 1passed
statistic1.73205 ± 1.7e-061.73205lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance usedp_value0.225403 ± 2.3e-070.225403lockedunder 0.01 % of the tolerance usedci_low2.03172 ± 2e-062.03172lockedunder 0.01 % of the tolerance usedci_high11.9683 ± 1.2e-0511.9683lockedunder 0.01 % of the tolerance usedse1.1547 ± 1.2e-061.1547lockedunder 0.01 % of the tolerance usedcohen_d1 ± 1e-061lockedunder 0.01 % of the tolerance usedr0012Welch t by hand, [0,2] vs [3,5]: t = -3/sqrt 2, Welch-Satterthwaite df = 2, p = 1 - |t|/sqrt(t^2+2)passed
statistic-2.12132 ± 2.1e-06-2.12132lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance usedp_value0.16795 ± 1.7e-070.16795lockedunder 0.01 % of the tolerance usedr0013Welch-Satterthwaite by hand, [1,2,3,4,5] vs [2,4,6]: t = -1/sqrt(11/6), df = 484/137passed
statistic-0.738549 ± 7.4e-07-0.738549lockedunder 0.01 % of the tolerance useddf3.53285 ± 3.5e-063.53285lockedunder 0.01 % of the tolerance usedse1.35401 ± 1.4e-061.35401lockedunder 0.01 % of the tolerance usedr0014paired t by hand, [10,12,14] vs [5,5,5]: differences 5,7,9, t = 7 sqrt(3)/2, df 2, p = 1 - t/sqrt(t^2+2)passed
statistic6.06218 ± 6.1e-066.06218lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance usedp_value0.0261483 ± 2.6e-080.0261483lockedunder 0.01 % of the tolerance usedestimate7 ± 7e-067lockedunder 0.01 % of the tolerance usedr0015one-way ANOVA of two groups equals t^2: [[1,2,3],[4,5,6]] gives F = 13.5 on (1, 4) df, the same p as the pooled t (0.0213116...), eta squared = 13.5/17.5passed
statistic13.5 ± 1.3e-0513.5lockedunder 0.01 % of the tolerance useddf1 ± 1e-061lockedunder 0.01 % of the tolerance useddf24 ± 4e-064lockedunder 0.01 % of the tolerance usedp_value0.0213116 ± 2.1e-080.0213116lockedunder 0.01 % of the tolerance usedeta_squared0.771429 ± 7.7e-070.771429lockedunder 0.01 % of the tolerance usedss_between13.5 ± 1.3e-0513.5lockedunder 0.01 % of the tolerance usedss_within4 ± 4e-064lockedunder 0.01 % of the tolerance usedr0016goodness of fit by hand, [30,10,20] against equal shares: chi2 = 10, df 2, p = exp(-5), Cohen w = sqrt(1/6)passed
statistic10 ± 1e-0510lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance usedp_value0.00673795 ± 6.7e-090.00673795lockedunder 0.01 % of the tolerance usedcohens_w0.408248 ± 4.1e-070.408248lockedunder 0.01 % of the tolerance usedr0017independence by hand, [[20,10,30],[10,20,30]]: chi2 = 20/3, df 2, p = exp(-10/3), Cramer V = sqrt(1/18)passed
statistic6.66667 ± 6.7e-066.66667lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance usedp_value0.035674 ± 3.6e-080.035674lockedunder 0.01 % of the tolerance usedcramers_v0.235702 ± 2.4e-070.235702lockedunder 0.01 % of the tolerance usedr00182 x 2 with Yates by hand, [[10,20],[20,10]]: chi2 = 4*(4.5^2)/15 = 5.4, df 1, p = erfc(sqrt 2.7)passed
statistic5.4 ± 5.4e-065.4lockedunder 0.01 % of the tolerance useddf1 ± 1e-061lockedunder 0.01 % of the tolerance usedp_value0.0201368 ± 2e-080.0201368lockedunder 0.01 % of the tolerance usedphi0.3 ± 3e-070.3lockedunder 0.01 % of the tolerance usedr0019chi-square with 4 df closed form p = exp(-x/2)(1 + x/2): p(6) = 4 exp(-3)passed
p_value0.199148 ± 2e-070.199148lockedunder 0.01 % of the tolerance usedr0020F(2, 4) closed form p = (1 + f/2)^-2: p(3) = 0.16, 5 % critical value 2(sqrt 20 - 1)passed
p_value0.16 ± 1.6e-070.16lockedunder 0.01 % of the tolerance usedcritical_value6.94427 ± 6.9e-066.94427lockedunder 0.01 % of the tolerance usedr0021Cauchy closed form, one-sided critical values past the median: t with 1 df, alternative greater, alpha = 0.75 has critical value tan(pi(1/2 - 3/4)) = -1; p(t = 1) = 1/4passed
critical_value-1 ± 1e-06-1lockedunder 0.01 % of the tolerance usedp_value0.25 ± 2.5e-070.25lockedunder 0.01 % of the tolerance usedreject_null= truetruelockedexact matchr0022Cauchy closed form: t with 1 df, alternative less, alpha = 0.75 has critical value +1; p(t = 1) = 3/4passed
critical_value1 ± 1e-061lockedunder 0.01 % of the tolerance usedp_value0.75 ± 7.5e-070.75lockedunder 0.01 % of the tolerance usedr0023non-integer df, F(2, n) closed form p = (1 + 2f/n)^(-n/2) for any n: F(2, 484/137) at f = 1.7passed
p_value0.303959 ± 3e-070.303959lockedunder 0.01 % of the tolerance usedr0024non-integer df, F(m, 2) closed form p = 1 - (m f/(2 + m f))^(m/2) for any m: F(2.7, 2) at f = 3.3passed
p_value0.239198 ± 2.4e-070.239198lockedunder 0.01 % of the tolerance usedr0025three-group ANOVA by hand, [[1,2,3],[2,3,4],[5,6,7]]: SSB = 26, SSW = 6, F = 13 on (2, 6) df, p = (1 + 2*13/6)^-3 = 27/4096 exactlypassed
statistic13 ± 1.3e-0513lockedunder 0.01 % of the tolerance useddf2 ± 2e-062lockedunder 0.01 % of the tolerance useddf26 ± 6e-066lockedunder 0.01 % of the tolerance usedp_value0.0065918 ± 6.6e-090.0065918lockedunder 0.01 % of the tolerance usedss_between26 ± 2.6e-0526lockedunder 0.01 % of the tolerance usedss_within6 ± 6e-066lockedunder 0.01 % of the tolerance usedeta_squared0.8125 ± 8.1e-070.8125lockedunder 0.01 % of the tolerance usedr0026Welch p at non-integer df 484/137, [1,2,3,4,5] vs [2,4,6]: NOT a closed form; p = 0.50621417165285 from Simpson integration of the t density (python math, 200000 panels, two routes agreeing to 1.4e-14), independent of this programpassed
p_value0.506214 ± 5.1e-070.506214lockedunder 0.01 % of the tolerance used
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
test | welch_t | Which test to run. | |
x | First sample (t tests). Any one unit; the estimate and interval come back in it. | ||
y | Second sample (paired, two-sample and Welch t), same unit as x. | ||
mu0 | 0.0 | Null value of the mean (one-sample) or of the mean difference (paired, two-sample), in the unit of x. | |
groups | ANOVA: one list of values per group. | ||
observed | Goodness of fit: observed counts per category. | ||
expected | Goodness of fit: expected counts or proportions per category (rescaled to the observed total). Left out: equal shares. | ||
ddof | 1 | 0 | Goodness of fit: parameters estimated from the data, taken off the degrees of freedom. |
table | Independence: contingency table of counts, rows by columns. | ||
yates | false | Independence: Yates' continuity correction (2 x 2 tables only). | |
statistic | 1 | p_value: the statistic to convert. | |
distribution | t | p_value: the null distribution. | |
df | 1 | p_value: degrees of freedom (numerator for F). At most 1e6: above that the p-value loses digits and the run is refused. | |
df2 | 1 | p_value: denominator degrees of freedom for F. At most 1e6: above that the p-value loses digits and the run is refused. | |
alternative | two_sided | Alternative hypothesis for t and z. Chi-square and F are always upper-tailed. | |
alpha | 1 | 0.05 | Significance level. |
confidence | 1 | 0.95 | Confidence level of the intervals. |
Readings
| Name | Unit | Meaning |
|---|---|---|
statistic | 1 | |
df | 1 | |
df2 | 1 | |
p_value | 1 | |
p_two_sided | 1 | |
p_upper | 1 | |
p_lower | 1 | |
critical_value | 1 | |
alpha | 1 | |
confidence | 1 | |
cohen_d | 1 | |
hedges_g | 1 | |
eta_squared | 1 | |
omega_squared | 1 | |
cohens_w | 1 | |
cramers_v | 1 | |
phi | 1 | |
effect_size | 1 | |
n_total | 1 |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.