Skip to content
Tutorials Center
My learning

Topics

Lesson 56 of 57 · Practice and Review

Statistics Formula Cheat Sheet

A compact statistics and probability cheat sheet: descriptive formulas, probability rules, distributions, confidence intervals, test choice, regression and Python equivalents.

This page collects the formulas and decisions you will use most, with the Python call that does each job, so you can check your hand calculations. Treat it as a map: for the reasoning behind any line, go back to the lesson on that topic. Bookmark it for exam revision and day-to-day analysis.

Descriptive statistics

Quantity Formula Python
Mean x̄ = Σxᵢ / n np.mean(x)
Median middle of sorted data np.median(x)
Sample variance s² = Σ(xᵢ − x̄)² / (n − 1) np.var(x, ddof=1)
Sample sd s = √s² np.std(x, ddof=1)
Range / IQR max − min / Q3 − Q1 np.ptp(x), np.subtract(*np.percentile(x, [75, 25]))
z-score z = (x − μ) / σ stats.zscore(x)
Outlier fences Q1 − 1.5·IQR, Q3 + 1.5·IQR
Covariance Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1) np.cov(x, y)
Correlation r = cov(x, y) / (sₓ s_y) np.corrcoef(x, y)

Rules of thumb: for skewed data prefer median and IQR; for symmetric data, mean and sd. The empirical rule for normal data: about 68%, 95% and 99.7% lie within 1, 2 and 3 standard deviations of the mean.

Probability rules

Rule Formula
Complement P(Aᶜ) = 1 − P(A)
Addition P(A ∪ B) = P(A) + P(B) − P(A ∩ B)
Conditional P(A∣B) = P(A ∩ B) / P(B)
Multiplication P(A ∩ B) = P(A∣B)·P(B)
Independence P(A ∩ B) = P(A)·P(B)
Total probability P(B) = Σ P(B∣Aᵢ)·P(Aᵢ)
Bayes P(A∣B) = P(B∣A)·P(A) / P(B)
Permutations / combinations n!/(n−k)! and n!/(k!(n−k)!)
Expectation / variance E[X] = Σ x·p(x), Var(X) = E[X²] − (E[X])²
Linear transform E[aX + b] = aE[X] + b, Var(aX + b) = a²Var(X)

Common distributions

Distribution Use Mean Variance SciPy
Bernoulli(p) one yes/no trial p p(1−p) stats.bernoulli(p)
Binomial(n, p) successes in n trials np np(1−p) stats.binom(n, p)
Poisson(λ) events per interval λ λ stats.poisson(lam)
Geometric(p) trials until first success 1/p (1−p)/p² stats.geom(p)
Uniform(a, b) equally likely on an interval (a+b)/2 (b−a)²/12 stats.uniform(a, b-a)
Exponential(λ) waiting time 1/λ 1/λ² stats.expon(scale=1/lam)
Normal(μ, σ) bell curve, sums and averages μ σ² stats.norm(mu, sigma)

Central limit theorem: for large n the sample mean is approximately N(μ, σ²/n) whatever the shape of the population (with finite variance). The standard error of the mean is σ/√n.

Estimation and tests

Task Formula
CI for a mean (σ unknown) x̄ ± t*·s/√n, df = n − 1
CI for a proportion p̂ ± z*·√(p̂(1−p̂)/n)
One-sample t t = (x̄ − μ₀)/(s/√n)
Two-sample (Welch) t t = (x̄₁ − x̄₂)/√(s₁²/n₁ + s₂²/n₂)
Paired t one-sample t on the differences
One proportion z z = (p̂ − p₀)/√(p₀(1−p₀)/n)
Two proportions z z = (p̂₁ − p̂₂)/√(p̂(1−p̂)(1/n₁ + 1/n₂))
Chi-square χ² = Σ (O − E)²/E
ANOVA F = MS_between / MS_within
Sample size, mean n = (z·σ/E)² for margin of error E
Sample size, proportion n = z²·p(1−p)/E²
Cohen's d (x̄₁ − x̄₂)/s_pooled

Common critical values: z* = 1.645 (90%), 1.96 (95%), 2.576 (99%).

flowchart TD
  A["What is your outcome?"] --> B{"Numeric"}
  A --> C{"Categories"}
  B --> D{"How many groups?"}
  D -->|"1 vs a value"| E["One-sample t"]
  D -->|"2 independent"| F["Welch t / Mann-Whitney"]
  D -->|"2 paired"| G["Paired t / Wilcoxon"]
  D -->|"3 or more"| H["ANOVA / Kruskal-Wallis"]
  B -->|"two numeric variables"| I["Correlation / regression"]
  C -->|"1 proportion"| J["z-test / binomial test"]
  C -->|"2 proportions"| K["Two-proportion z / chi-square"]
  C -->|"2 categorical variables"| L["Chi-square independence"]

Regression

Item Formula
Line ŷ = b₀ + b₁x
Slope / intercept b₁ = r·s_y/sₓ, b₀ = ȳ − b₁x̄
R² 1 − SSE/SST
Residual standard error √(SSE/(n − k − 1))
Slope t-test t = b₁/SE(b₁), df = n − k − 1
Adjusted R² 1 − (1 − R²)(n − 1)/(n − k − 1)
Logistic model ln(p/(1−p)) = β₀ + β₁x, odds ratio e^β
VIF 1/(1 − R²ⱼ)

Bayesian and resampling

  • Posterior ∝ likelihood × prior.
  • Beta(α, β) prior with k successes in n trials gives Beta(α + k, β + n − k).
  • Bootstrap: resample with replacement, recompute the statistic, take percentiles.
  • Permutation test: shuffle labels, compute the statistic, p = share at least as extreme.
  • Multiple tests: Bonferroni α/m; Holm step-down; Benjamini-Hochberg for FDR.

A runnable toolbox

The code below wraps several of the formulas so that you can verify answers quickly.

Python A small statistics toolbox

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Distribution lookups in one place

SciPy distributions all share the same methods: pdf/pmf (density or mass), cdf (probability up to x), sf (the upper tail, 1 − cdf), ppf (the inverse of the cdf, giving quantiles) and rvs (random draws). Learn these five and you can answer almost every table-lookup question.

Python The five SciPy methods

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which formula gives the standard error of the sample mean?

    SE = s/sqrt(n): it shrinks as the sample grows.
  2. 2. You want P(X > 130) for a normal variable in SciPy. Which method is the most direct?

    sf is the survival function, 1 - cdf, the upper-tail probability.
  3. 3. A comparison of the means of 4 independent groups of numeric data with roughly normal errors calls for:

    ANOVA compares means of three or more independent groups; Kruskal-Wallis is the rank-based alternative.
  4. 4. Using the sample-size formula for a mean, what happens if you want half the margin of error?

    n is proportional to 1/E squared, so halving E multiplies n by four.

Summary

  • Descriptive formulas, probability rules, distributions and test statistics fit on a page; the hard part is choosing the right one.
  • Choose the test from the outcome type, the number of groups and whether groups are paired.
  • SciPy distributions share pdf/pmf, cdf, sf, ppf, rvs.
  • Always accompany a test with an interval and an effect size.

Next: Common Statistical Mistakes