HomeAll tracks · pricing · account
Python11 apps · Python, SQL & data
Start free Log in

BitSize Python · Statistical Tests

A hundred tests. Five ideas. One map.

Every statistical test as one station on a map: when to use it, and when not.

Track your progress

Save where you are and see what you remember.

Sign up free →
Part 1

How every test works

0/6

The null world built by shuffling, p-values as areas, α and tails, errors and power, effect sizes, the five engines and the multiple-testing tax.

  1. 01 Signal or noise? The test behind every teststats.permutation_test Up next
  2. 02 The p-value is an areastats.norm.sf · stats.t.sf Free account
  3. 03 α and the critical region: one tail or twostats.norm.ppf · stats.t.ppf · alternative= Free account
  4. 04 Two ways to be wrong: errors and powerTTestIndPower · solve_power 🔒 Subscribe
  5. 05 Surprise vs size: effect sizes and intervalsCohen’s d · ttest_ind(...).confidence_interval() 🔒 Subscribe
  6. 06 Reading the Atlas: five engines and the many-tests taxmultipletests (Bonferroni · Holm · BH) 🔒 Subscribe
Part 2

One sample vs a value

0/7

z and t for a mean, one proportion, Poisson rates, a variance vs a target, sign and Wilcoxon tests, outliers.

  1. 07 z-test for a mean, when σ is knownstats.norm.sf · σ ÷ √n by hand 🔒 Subscribe
  2. 08 The one-sample t-teststats.ttest_1samp · confidence_interval() · alternative= 🔒 Subscribe
  3. 09 One proportion: exact binomial vs zstats.binomtest · proportion_ci() · the one-proportion z by hand 🔒 Subscribe
  4. 10 Counts per unit time: Poisson rate testsstats.poisson.cdf / sf · stats.poisson_means_test 🔒 Subscribe
  5. 11 A variance vs a target: the χ² variance teststats.chi2.sf · stats.chi2.cdf · stats.chi2.ppf 🔒 Subscribe
  6. 12 A median vs a value: sign and Wilcoxon testsstats.binomtest(k, n, 0.5) · stats.wilcoxon 🔒 Subscribe
  7. 13 Is that point an outlier? Grubbs and DixonGrubbs by hand (stats.t.ppf) · Dixon’s Q 🔒 Subscribe
Part 3

Two groups

0/9

Two-sample z, Student and Welch t, paired t, two variances, Mann–Whitney, Mood, two proportions, permutation and bootstrap.

  1. 14 Two means, σ known: the two-sample zstats.norm.sf · ttest_ind(equal_var=False) 🔒 Subscribe
  2. 15 Student's pooled t-teststats.ttest_ind(equal_var=True) · f_oneway 🔒 Subscribe
  3. 16 Welch's t-test: the defaultstats.ttest_ind(equal_var=False) 🔒 Subscribe
  4. 17 Paired t: a one-sample t on the differencesstats.ttest_rel · ttest_1samp on the differences 🔒 Subscribe
  5. 18 Two variances: the F-test and Pitman–Morganstats.f.sf / f.cdf · stats.levene · pearsonr(x + y, x − y) 🔒 Subscribe
  6. 19 Mann–Whitney: comparing by ranksstats.mannwhitneyu 🔒 Subscribe
  7. 20 Mood's median teststats.median_test 🔒 Subscribe
  8. 21 Two proportions: z, χ² and Fisherstats.chi2_contingency · stats.fisher_exact 🔒 Subscribe
  9. 22 Permutation and bootstrap testsstats.permutation_test · stats.bootstrap 🔒 Subscribe
Part 4

Many groups

0/10

ANOVA and Welch ANOVA, equal spreads, Tukey, Dunnett, contrasts and Scheffé, Kruskal–Wallis, Friedman and Cochran Q, Kendall’s W.

  1. 23 One-way ANOVA: why not many t-testsstats.f_oneway · MS between ÷ MS within 🔒 Subscribe
  2. 24 Welch's ANOVA, when spreads differanova_oneway(use_var='unequal') · stats.f_oneway 🔒 Subscribe
  3. 25 Equal spreads? Levene, Bartlett, Hartley, Cochranstats.levene · stats.bartlett · Fmax and C by hand 🔒 Subscribe
  4. 26 Which pairs differ? Tukey HSDTukey–Kramer by hand · qsturng (studentized range) 🔒 Subscribe
  5. 27 Everyone against a control: Dunnettstats.dunnett 🔒 Subscribe
  6. 28 Planned contrasts and Scheffécontrast t by hand · Scheffé (stats.f.ppf) 🔒 Subscribe
  7. 29 Is the top group really the best?Tukey–Kramer vs the top group (qsturng) 🔒 Subscribe
  8. 30 Kruskal–Wallis and Dunn's follow-upstats.kruskal · Dunn’s test by hand · multipletests 🔒 Subscribe
  9. 31 Repeated measures by ranks: Friedman and Cochran's Qstats.friedmanchisquare · cochrans_q 🔒 Subscribe
  10. 32 Do the judges agree? Kendall's WW by hand · stats.friedmanchisquare 🔒 Subscribe
Part 5

Designs with structure

0/6

Two-way ANOVA, unequal cells, non-additivity, nested designs, random effects, Hotelling’s T².

  1. 33 Two-way ANOVA: main effects and interactionsmf.ols with * · sm.stats.anova_lm 🔒 Subscribe
  2. 34 Unequal cells: Type I, II and III sums of squaresanova_lm typ=1 · 2 · 3 · C(x, Sum) 🔒 Subscribe
  3. 35 Tukey's test for non-additivityTukey’s 1-df test by hand · stats.f.sf · np.log 🔒 Subscribe
  4. 36 Nested designsnested F-ratios by hand · stats.f.sf · f_oneway on class means 🔒 Subscribe
  5. 37 Random effects and variance componentsvariance components by hand · stats.f_oneway · stats.t.interval 🔒 Subscribe
  6. 38 Many outcomes at once: Hotelling's T²Hotelling’s T² by hand · np.cov · np.linalg.solve · stats.f.sf 🔒 Subscribe
Part 6

Counts and tables

0/9

Goodness of fit, independence, Fisher’s exact test, homogeneity, the G-test, McNemar, trend tests, Mantel–Haenszel, transitions.

  1. 39 Goodness of fit for categoriesstats.chisquare · ddof · residuals (O − E)/√E 🔒 Subscribe
  2. 40 Independence in an r×c tablepd.crosstab · stats.chi2_contingency · stats.contingency.association 🔒 Subscribe
  3. 41 Small counts: Fisher's exact teststats.fisher_exact · stats.hypergeom · stats.barnard_exact · stats.boschloo_exact 🔒 Subscribe
  4. 42 Many groups, one mix? Homogeneitystats.chi2_contingency · pd.crosstab · residuals · Bonferroni pairs 🔒 Subscribe
  5. 43 The G-test: likelihood-ratio χ²stats.power_divergence · chi2_contingency(lambda_=) · partitioning G 🔒 Subscribe
  6. 44 Before and after, yes or no: McNemarstats.binomtest on the switchers · McNemar χ² · statsmodels mcnemar 🔒 Subscribe
  7. 45 Ordered groups: the Cochran–Armitage trend testCochran–Armitage by hand · stats.norm.sf · chi2_contingency · stats.pearsonr 🔒 Subscribe
  8. 46 Strata: Mantel–Haenszel and Simpson's paradoxStratifiedTable (statsmodels) · test_null_odds · oddsratio_pooled · chi2_contingency 🔒 Subscribe
  9. 47 Does what follows depend on what came before?pd.crosstab(x[:-1], x[1:]) · chi2_contingency · np.corrcoef 🔒 Subscribe
Part 7

Relationships

0/9

Testing r, Fisher’s z, Spearman and Kendall, the slope test, lack of fit, multiple regression, Durbin–Watson, the linear-model view.

  1. 48 Is r zero? Testing a correlationstats.pearsonr · .confidence_interval() · t by hand with stats.t.sf 🔒 Subscribe
  2. 49 Comparing correlations: Fisher's zstats.pearsonr · np.arctanh / np.tanh · stats.norm.sf 🔒 Subscribe
  3. 50 Spearman and Kendall: correlation by ranksstats.spearmanr · stats.kendalltau (τ-b) · stats.pearsonr on .rank() 🔒 Subscribe
  4. 51 The slope test is the r teststats.linregress · stats.pearsonr · t = r√(n − 2)/√(1 − r²) 🔒 Subscribe
  5. 52 Is it really a line? Lack-of-fitsmf.ols('height ~ dose') vs smf.ols('height ~ C(dose)') · sm.stats.anova_lm 🔒 Subscribe
  6. 53 Many predictors: t per coefficient, F for the lotsmf.ols('price_k ~ size_m2 + rooms + age') · .pvalues · .fvalue · variance_inflation_factor · anova_lm 🔒 Subscribe
  7. 54 Autocorrelated errors: Durbin–Watsonstatsmodels durbin_watson · one Cochrane–Orcutt step · stats.linregress on differences 🔒 Subscribe
  8. 55 Everything is a linear modelsmf.ols with ~ 1, a 0/1 column, C(group) and a number · .pvalues · .f_pvalue 🔒 Subscribe
  9. 56 Wald, score and likelihood ratiosmf.logit · .pvalues (Wald) · .llf − .llnull (LR) · the score z by hand 🔒 Subscribe
Part 8

Shape and fit

0/6

Shapiro–Wilk, Kolmogorov–Smirnov and Lilliefors, Anderson–Darling, two-sample and K-sample fit, choosing a model honestly.

  1. 57 Is it normal? Q–Q plots and Shapiro–Wilkstats.shapiro · stats.probplot · stats.skew 🔒 Subscribe
  2. 58 Kolmogorov–Smirnov and Lillieforsstats.kstest · statsmodels lilliefors 🔒 Subscribe
  3. 59 Anderson–Darling: watching the tailsstats.anderson · statsmodels lilliefors · stats.kurtosis 🔒 Subscribe
  4. 60 Two distributions: two-sample KSstats.ks_2samp · stats.mannwhitneyu · np.searchsorted 🔒 Subscribe
  5. 61 Several samples, one distribution?stats.anderson_ksamp · stats.kruskal · stats.ks_2samp 🔒 Subscribe
  6. 62 Choosing a model: testing the fit honestlyparametric bootstrap · stats.kstest · stats.goodness_of_fit 🔒 Subscribe
Part 9

Randomness and order

0/6

Runs, turning points and trend, serial correlation, interleaved samples, which population made a series, streaks.

  1. 63 Runs: is this sequence random?runstest_1samp(x, cutoff='median') · np.median · stats.norm 🔒 Subscribe
  2. 64 Trend: Cox–Stuart and Mann–Kendallstats.kendalltau(np.arange(n), x) · stats.binomtest · np.triu_indices (Sen’s slope) 🔒 Subscribe
  3. 65 Serial correlation: von Neumann and Ljung–Boxacorr_ljungbox(x, lags=[10]) · acf(x, nlags=…) · np.diff (von Neumann ratio) 🔒 Subscribe
  4. 66 Two samples interleaved: Wald–Wolfowitzrunstest_2samp · np.sort · stats.norm.cdf · stats.mannwhitneyu 🔒 Subscribe
  5. 67 Which population made this series?stats.norm.logpdf · np.exp · posterior odds = likelihood ratio × prior odds 🔒 Subscribe
  6. 68 Streaks and the hot handrunstest_1samp · rng.permutation · a longest-streak statistic 🔒 Subscribe
Part 10

Deciding between hypotheses

0/6

Neyman–Pearson, likelihood ratios, most powerful tests, sequential testing, peeking, equivalence and Bayes factors.

  1. 69 Simple vs simple: the Neyman–Pearson picturestats.norm.isf · stats.norm.sf · stats.norm.logpdf (the likelihood ratio) 🔒 Subscribe
  2. 70 Likelihood ratio testsstats.poisson.logpmf · stats.chi2.sf · stats.binomtest (the exact check) 🔒 Subscribe
  3. 71 Uniformly most powerful testsstats.norm.sf · stats.norm.isf · alternative= 🔒 Subscribe
  4. 72 Sequential testing: the SPRTnp.cumsum of log-likelihood steps · np.argmax for the first crossing 🔒 Subscribe
  5. 73 Peeking without a plantwo-proportion z at each look · np.cumsum · default_rng A/A simulation 🔒 Subscribe
  6. 74 Equivalence (TOST) and Bayes factorsttost_ind (statsmodels) · stats.ttest_ind(equal_var=False) · a BIC Bayes factor by hand 🔒 Subscribe
Part 11

Circular data

0/4

Angles and times of day: the circular mean, the Rayleigh test, fit for angles, two or more circular samples.

  1. 75 Angles break the mean: the Rayleigh testnp.cos / np.sin · stats.circmean · Rayleigh Z = n·R̄² by hand 🔒 Subscribe
  2. 76 Fit for angles: Kuiper and WatsonKuiper V and Watson U² by hand · stats.kstest (for contrast) 🔒 Subscribe
  3. 77 Two circular samplesWatson–Williams by hand · stats.f.sf · stats.ttest_ind (for contrast) 🔒 Subscribe
  4. 78 Several circular groups: Watson–WilliamsWatson–Williams by hand · stats.f.sf 🔒 Subscribe
Part 12

Case files

0/4

Real questions end to end: plan the route on the Atlas, run it, report it, and see what the tempting wrong test would have said.

  1. 79 Case file: did the redesign change basket sizes?stats.ttest_ind(equal_var=False) · stats.levene · stats.mannwhitneyu · stats.poisson_means_test 🔒 Subscribe
  2. 80 Case file: four clinics and a waiting listanova_oneway(use_var='unequal') · stats.ttest_ind(equal_var=False) · multipletests(method='holm') 🔒 Subscribe
  3. 81 Case file: survey tablesStratifiedTable (statsmodels) · stats.mannwhitneyu · Cochran–Armitage as √N·r · chi2_contingency 🔒 Subscribe
  4. 82 Case file: wind directions and sensor driftstats.circmean · Rayleigh by hand · stats.kendalltau with prewhitening · stats.ttest_1samp · Ljung–Box by hand 🔒 Subscribe