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

BitSize Python · Statistics & Probability

See the chance in your data.

The statistics that matter, one idea a day, with NumPy, SciPy and statsmodels.

rng.normal(250, 2, n)n = 0

Track your progress

Save where you are and see what you remember.

Sign up free →
Part 1

Describing data

0/6

Centre, spread, shape, quantiles and box plots, z-scores, correlation.

  1. 01 Centre: mean, median and the pull of outliersSeries.mean · Series.median · Series.mode · stats.trim_mean Up next
  2. 02 Spread: range, IQR, variance and standard deviationnp.ptp · stats.iqr · Series.var · Series.std · ddof · stats.median_abs_deviation · coefficient of variation Free account
  3. 03 Shape: skewness, tails and transformationsnp.histogram · stats.skew · stats.kurtosis · Series.skew · np.log Free account
  4. 04 Quantiles, percentiles and box plotsnp.percentile · Series.quantile · IQR fences · box plots · stats.percentileofscore 🔒 Subscribe
  5. 05 z-scores: how unusual is this value?(x − mean) / sd · stats.zscore · 68–95–99.7 rule · |z| > 3 · robust z with stats.median_abs_deviation 🔒 Subscribe
  6. 06 Correlation: Pearson, Spearman and their trapsstats.pearsonr · stats.spearmanr · Series.corr · DataFrame.corr · r² 🔒 Subscribe
Part 2

Probability

0/6

Rules, conditional probability and Bayes, random variables, Monte Carlo, the law of large numbers.

  1. 07 Probability rules: and, or, notSeries.mean on True/False · complement 1 − P · addition rule · P(A)·P(B) · rng.random 🔒 Subscribe
  2. 08 Conditional probability and Bayes' rulepd.crosstab(normalize='index') · P(A | B) = P(A and B) / P(B) · Bayes' rule · natural frequencies 🔒 Subscribe
  3. 09 Random variables and expected valuepmf as value → probability · E[X] = Σ x·p · Var = Σ (x − μ)²·p · E[aX + b] · stats.rv_discrete 🔒 Subscribe
  4. 10 Monte Carlo: answer it by simulationnp.random.default_rng · rng.random · rng.integers · rng.choice · vectorised draws · share of simulated outcomes 🔒 Subscribe
  5. 11 The law of large numbers: why small samples lienp.cumsum · running means · rng.binomial · the 1/√n rule · groupby.head 🔒 Subscribe
  6. 12 Counting: permutations and combinationsmath.factorial · math.perm · math.comb · scipy.special.comb · the birthday problem 🔒 Subscribe
Part 3

Distributions

0/7

Binomial, Poisson, normal, exponential, t, χ² and F; the scipy.stats toolkit; normality checks.

  1. 13 The binomial distribution: successes out of n triesBernoulli trials · stats.binom(n, p) · pmf · cdf · sf · mean n·p · variance n·p·(1 − p) · rvs 🔒 Subscribe
  2. 14 The Poisson distribution: counts of eventsstats.poisson(mu) · pmf · cdf · sf · ppf · mean = variance · binomial limit · rescaling the rate 🔒 Subscribe
  3. 15 The normal distribution: the bell curve and its areasstats.norm(loc, scale) · pdf · cdf · sf · ppf · standardising · 68–95–99.7 🔒 Subscribe
  4. 16 Waiting times: the exponential distributionstats.expon(scale=1/λ) · pdf · cdf · sf · ppf · rng.exponential · memorylessness 🔒 Subscribe
  5. 17 The t, χ² and F family: the shapes behind the testsstats.t · stats.chi2 · stats.f · ppf for critical values · sf for tail areas · degrees of freedom 🔒 Subscribe
  6. 18 The scipy.stats toolkit: freeze, fit and question a distributionfrozen distributions · pdf · cdf · sf · ppf · isf · interval · rvs(random_state=) · norm.fit · expon.fit(floc=0) · lognorm.fit · logpdf().sum() 🔒 Subscribe
  7. 19 Is it normal? Q–Q plots and normality testsstats.probplot · stats.shapiro · stats.skew · stats.kurtosis · Q–Q plot · groupby checks 🔒 Subscribe
Part 4

Estimation

0/6

Sampling distributions, the central limit theorem, standard errors, confidence intervals, the bootstrap.

  1. 20 Sampling distributions: every sample tells a different storyrng.choice(size=(reps, n)) · mean(axis=1) · sampling distribution · σ/√n · statistic vs parameter 🔒 Subscribe
  2. 21 The central limit theorem: why averages turn out normalcentral limit theorem · stats.norm(μ, σ/√n) · stats.skew of means · normal approximation to a proportion 🔒 Subscribe
  3. 22 Standard error: how precise is an estimate?SE = s/√n · stats.sem · Series.sem · SE of a proportion · SE of a difference · error bars 🔒 Subscribe
  4. 23 Confidence intervals: a range of plausible valuesstats.t.interval · stats.t.ppf · proportion_confint (Wilson, normal) · coverage · width against n 🔒 Subscribe
  5. 24 The bootstrap: confidence intervals by resamplingrng.choice(replace=True) · resampling rows · percentile interval · stats.bootstrap · bootstrap SE 🔒 Subscribe
  6. 25 How big a sample? Margin of error and nmargin = critical value × SE · n = (z·σ/E)² · n = z²·p(1−p)/E² · math.ceil · stats.norm.ppf · stats.t.ppf 🔒 Subscribe
Part 5

Testing ideas

0/6

Hypotheses and p-values, one-sample tests, errors and power, effect sizes, multiple comparisons.

  1. 26 Hypothesis testing: the logic, by shufflingH₀ and H₁ · test statistic · permutation test · p-value · α and the decision · stats.permutation_test 🔒 Subscribe
  2. 27 One-sample tests: is it different from a target?stats.ttest_1samp · t = (mean − target) / SE · alternative · confidence_interval · stats.binomtest 🔒 Subscribe
  3. 28 Type I and II errors and power: will your test see a real effect?α · β · power = 1 − β · TTestIndPower · solve_power · power by simulation · Cohen's d 🔒 Subscribe
  4. 29 Effect sizes: how big, not just whetherCohen's d · pooled SD · difference in means + CI · risk difference · relative risk · odds ratio · r and r² 🔒 Subscribe
  5. 30 Many tests, many false alarms: Bonferroni, Holm and Benjamini–Hochbergfamily-wise error 1 − 0.95ᵏ · Bonferroni · Holm · Benjamini–Hochberg · multipletests · subgroup fishing 🔒 Subscribe
  6. 31 Honest testing: peeking, p-hacking and what a p-value meansoptional stopping · forking paths · P(data | H₀) vs P(H₀ | data) · false discoveries · pre-registration · effect + CI + p 🔒 Subscribe
Part 6

Comparing groups

0/8

Welch and paired t, rank tests, ANOVA and Tukey, proportions, χ² tests, Fisher.

  1. 32 Two groups: Welch's t-teststats.ttest_ind(equal_var=False) · Welch vs Student · SE of a difference · Welch df · confidence_interval() · Cohen's d 🔒 Subscribe
  2. 33 Paired data: the same units measured twicestats.ttest_rel · differences · ttest_1samp on the differences · SE of paired data · d_z · Welch on change scores 🔒 Subscribe
  3. 34 Rank tests: Mann–Whitney and Wilcoxonstats.rankdata · stats.mannwhitneyu · U as wins · rank-biserial r · stats.wilcoxon · signed ranks 🔒 Subscribe
  4. 35 One-way ANOVA: three or more groupsstats.f_oneway · between and within variance · the F distribution · ols + anova_lm · η² · stats.levene 🔒 Subscribe
  5. 36 Which groups differ? Tukey HSD and Kruskal–Wallispost-hoc pairs · Tukey HSD · studentized range (qsturng) · simultaneous CIs · stats.kruskal · η²_H 🔒 Subscribe
  6. 37 Comparing proportions: two rates, one gapproportions_ztest · confint_proportions_2indep · risk difference · relative risk · pooled SE · z² = χ² 🔒 Subscribe
  7. 38 χ² tests: goodness of fit and independencestats.chisquare · stats.chi2_contingency · expected counts · the expected ≥ 5 rule · standardised residuals · Cramér's V 🔒 Subscribe
  8. 39 Fisher's exact test, and choosing the right teststats.fisher_exact · stats.hypergeom · stats.contingency.odds_ratio · McNemar (statsmodels mcnemar) · the decision map: data type × groups × paired → test 🔒 Subscribe
Part 7

Regression with statsmodels

0/8

OLS and its summary, multiple and categorical predictors, interactions, diagnostics, logistic and Poisson models.

  1. 40 Simple linear regression: the best straight lineleast squares · residuals · SSE · smf.ols · .params · .predict · stats.linregress · r² = corr² · regression to the mean 🔒 Subscribe
  2. 41 Reading a statsmodels summarysummary() · .params · .bse · .tvalues · .pvalues · .conf_int() · .rsquared_adj · .fvalue · get_prediction · summary_frame 🔒 Subscribe
  3. 42 Multiple regression: holding other things equalsmf.ols(y ~ x1 + x2) · holding others constant · confounding · partial effects · rsquared_adj · standardised coefficients · VIF 🔒 Subscribe
  4. 43 Categorical predictors: dummies and reference levelsC(x) · dummy coding · Treatment(reference=…) · gaps from the reference · regression F = ANOVA F · parallel lines 🔒 Subscribe
  5. 44 Interactions: when one effect depends on anotherx * z vs x + z · x:z · slope per group · centring with I(x - c) · anova_lm(small, big) · interaction on the log scale 🔒 Subscribe
  6. 45 Regression diagnostics: checking the assumptionsresid vs fitted · probplot(res.resid) · het_breuschpagan · cov_type=HC3 · cooks_distance · variance_inflation_factor · np.log(y) 🔒 Subscribe
  7. 46 Logistic regression: predicting yes or nosmf.logit · fit(disp=0) · log-odds · np.exp(params) odds ratios · conf_int · predict · classification threshold · accuracy against the base rate 🔒 Subscribe
  8. 47 Poisson regression: modelling countssmf.glm(family=sm.families.Poisson()) · smf.poisson · rate ratios np.exp(params) · Pearson χ²/df · smf.negativebinomial · exposure 🔒 Subscribe
Part 8

Beyond the basics

0/5

Two-way ANOVA, Bayesian updating, time series, resampling, practical significance.

  1. 48 Two-way ANOVA: two factors at oncesmf.ols('y ~ C(a) * C(b)') · sm.stats.anova_lm(typ=2) · main effects · interaction · interaction plots · η² per term 🔒 Subscribe
  2. 49 Bayesian updating: beliefs that learn from dataprior · likelihood · posterior · stats.beta(a + successes, b + failures) · .interval(0.95) · P(B > A) by simulation · credible vs confidence interval 🔒 Subscribe
  3. 50 Time series: trend, season and autocorrelationsort_values(date) · rolling(7).mean() · shift · diff · seasonal_decompose · acf · Series.autocorr 🔒 Subscribe
  4. 51 Resampling: permutation, bootstrap and cross-validationrng.permuted · stats.permutation_test · bootstrap rows · np.percentile · k-fold CV · Polynomial.fit · RMSE 🔒 Subscribe
  5. 52 Practical significance: does the difference matter?smallest effect of interest · CI against a margin · ttost_ind · TOST by hand · 90% CI · cost break-even 🔒 Subscribe
Part 9

Case files

0/5

End-to-end studies: an A/B test, a clinical trial, quality control, pricing, a survey.

  1. 53 Case file: did the new checkout work?confint_proportions_2indep · NormalIndPower · ttest_ind(equal_var=False) · mannwhitneyu · stats.bootstrap · multipletests(holm) 🔒 Subscribe
  2. 54 Case file: does the drug lower blood pressure?baseline SMD · ttest_rel · Welch ttest_ind · Cohen's d · mannwhitneyu · ANCOVA smf.ols · interaction test · NNT 🔒 Subscribe
  3. 55 Case file: are the espresso machines in spec?Cp · Cpk · norm.cdf + norm.sf out-of-spec · X-bar chart ±3σ/√n · stats.levene · two-way anova_lm · Holm 🔒 Subscribe
  4. 56 Case file: pricing a house fairlynp.log(price_k) · smf.ols · % effects 100(e^b − 1) · het_breuschpagan · get_prediction · obs_ci · residual flags · k-fold CV 🔒 Subscribe
  5. 57 Case file: what makes customers recommend us?chi2_contingency · multipletests (Holm) · stats.kruskal · smf.logit · odds ratios · likelihood-ratio test · predict for personas 🔒 Subscribe