Statistics Basics
mean · median · std · variance · z-score · p-value · confidence intervals · hypothesis testing
Sheet 1 of 6
Stats & Math
Beginner
Printable
Descriptive Statistics
Mean (Average)
x̄ =
Σ xᵢ
n
Sum of all values ÷ count of values. Sensitive to outliers.
Median
Middle value when sorted.
Even n: avg of two middle values
Even n: avg of two middle values
Not affected by outliers — use for skewed data.
Mode
Most frequently occurring value.
Can be multi-modal or none.
Can be multi-modal or none.
Only measure that works for categorical data.
Variance
s2 =
Σ(xᵢ − x̄)2
n − 1
Average squared deviation from the mean. n−1 = sample variance (Bessel's correction).
Standard Deviation
s = √s2
=
√
Σ(xᵢ−x̄)2
n−1
Square root of variance. Same units as data. Most common spread measure.
Range & IQR
Range = max − min
IQR = Q3 − Q1
IQR = Q3 − Q1
IQR = Interquartile Range. Middle 50% of data. Outlier: < Q1−1.5·IQR or > Q3+1.5·IQR.
Quick Example — Dataset
Data: [4, 7, 13, 2, 1, 7] Mean = (4+7+13+2+1+7)/6 = 5.67 Sorted = [1,2,4,7,7,13] Median = (4+7)/2 = 5.5 Mode = 7 (appears twice) Variance = 14.67 (sample) Std Dev = 3.83 Range = 13 - 1 = 12 Q1 = 2 Q3 = 7 IQR = 7 - 2 = 5
Population vs Sample: Use n for population variance (σ²), n−1 for sample variance (s²). Most real-world data is a sample — use n−1 to get an unbiased estimate.
Z-Score & Standardization
Z-Score Formula
z =
x − μ
σ
x = value · μ = mean · σ = std deviation
Interpretation
z = 0 → exactly at the mean z = 1 → 1 std dev above mean z = -2 → 2 std devs below mean z = 1.96 → top 2.5% (one tail) z = ±1.96 → 95% of data lies here z = ±2.58 → 99% of data lies here
| % of data | Within ±σ |
|---|---|
| 68.27 % | ±1σ from mean |
| 95.45 % | ±2σ from mean |
| 99.73 % | ±3σ from mean (Empirical Rule) |
Standardization use case: Z-scores let you compare values from different distributions. Required before many ML algorithms (k-NN, SVM, neural nets).
Key Distributions
Normal Distribution
X ~ N(μ, σ2)
Mean = μ, Std Dev = σ, Symmetric bell shape
Mean = μ, Std Dev = σ, Symmetric bell shape
Central Limit Theorem: sample means are approximately normal for large n (n ≥ 30).
Binomial Distribution
P(X=k) = C(n,k) · pk · (1−p)n−k
Mean = np, Var = np(1−p)
Mean = np, Var = np(1−p)
n trials, p = prob of success each trial. Count of successes in n trials.
Poisson Distribution
P(X=k) =
λk · e−λ
k!
Mean = Var = λ
λ = expected events per interval. Use for rare events (call centre, website hits).
Hypothesis Testing
Null & Alternative Hypothesis
H0: no effect / no difference
H1: effect exists / difference
H1: effect exists / difference
We test whether data gives enough evidence to reject H₀. We never "prove" H₀.
p-value
p-value ≤ α → reject H0
p-value > α → fail to reject H0
p-value > α → fail to reject H0
α (significance level) = 0.05 (5%) is the most common threshold. The p-value is the probability of seeing data this extreme if H₀ is true.
Test Statistic — One-Sample t-test
t =
x̄ − μ0
s
√n
x̄ = sample mean, μ₀ = hypothesized mean, s = sample std dev, n = sample size.
| Error Type | What happened |
|---|---|
| Type I (α) | Reject H₀ when it was true (false positive) |
| Type II (β) | Fail to reject H₀ when H₁ was true (false negative) |
| Power (1−β) | Probability of correctly rejecting a false H₀ |
Choosing the Right Test
1 group vs known value: → one-sample t-test 2 independent groups: → independent t-test Same group, before/after: → paired t-test 3+ groups: → ANOVA 2 categorical variables: → Chi-square test Relationship (numeric vs numeric): → Pearson correlation → Linear regression
p-value ≠ probability H₀ is true. It's the probability of getting data this extreme assuming H₀ is true. Statistical significance doesn't always mean practical importance — always check effect size too.
Confidence Intervals
95% Confidence Interval for Mean
CI = x̄ ±
zα/2
·
σ
√n
zα/2 = 1.96 for 95% CI · 2.576 for 99% CI · 1.645 for 90% CI
t-based CI (unknown σ, small n)
CI = x̄ ±
tα/2, df
·
s
√n
df = degrees of freedom = n − 1. Use t-distribution when n < 30 or σ unknown.
Worked Example
Sample: n=25, x̄=50, s=10, 95% CI t* = 2.064 (df=24, two-tailed) SE = 10 / √25 = 2.0 CI = 50 ± 2.064 × 2.0 = 50 ± 4.13 = [45.87, 54.13] Interpretation: We are 95% confident the true mean lies in [45.87, 54.13]
Correlation & Covariance
Pearson Correlation Coefficient
r =
Cov(X,Y)
σX · σY
Range: −1 to +1. r = +1 perfect positive · r = 0 no linear · r = −1 perfect negative.
| |r| value | Strength |
|---|---|
| 0.00 – 0.19 | Very weak |
| 0.20 – 0.39 | Weak |
| 0.40 – 0.59 | Moderate |
| 0.60 – 0.79 | Strong |
| 0.80 – 1.00 | Very strong |
Correlation ≠ Causation. Two variables can be strongly correlated without one causing the other — always check for confounding variables.
Sampling & Central Limit Theorem
Standard Error of the Mean (SEM)
SE =
σ
√n
How much sample means vary around the population mean. Decreases as n grows — collect more data for more precise estimates.
Central Limit Theorem (CLT)
For large n (≥ 30):
X̄ ~ N(μ, σ2/n)
X̄ ~ N(μ, σ2/n)
Sample means follow a normal distribution regardless of the population's shape — if sample size is large enough. Foundation of most inferential statistics.
| Sampling Type | How |
|---|---|
| Simple Random | Every unit has equal probability |
| Stratified | Divide into strata, sample each |
| Cluster | Randomly select groups, sample all |
| Systematic | Every k-th unit in list |
| Convenience | Easiest to reach (biased!) |
Effect Size & Statistical Power
Cohen's d (Effect Size)
d =
x̄1 − x̄2
spooled
d = 0.2 small · d = 0.5 medium · d = 0.8 large (Cohen's conventions).
| Concept | Meaning |
|---|---|
| α (alpha) | Significance level — prob of Type I error. Usually 0.05. |
| β (beta) | Prob of Type II error. Usually set to 0.20. |
| Power (1−β) | Prob of detecting a true effect. Usually ≥ 0.80. |
| Sample size ↑ | Reduces SE, increases power, narrows CI. |
Symbols Quick Reference
| Symbol | Meaning | Pop / Sample |
|---|---|---|
| μ (mu) | Mean | Population |
| x̄ (x-bar) | Mean | Sample |
| σ (sigma) | Standard deviation | Population |
| s | Standard deviation | Sample |
| σ² | Variance | Population |
| s² | Variance | Sample |
| N / n | Size | Pop / Sample |
| α (alpha) | Significance level | — |
| H₀ / H₁ | Null / Alternative hypothesis | — |
| r | Pearson correlation | Sample |
| ρ (rho) | Pearson correlation | Population |
| SE | Standard Error of Mean | — |
Statistics Basics Mastery Checklist
| Descriptive Stats | Key point |
|---|---|
| Calculate mean/median/mode | Σxᵢ/n |
| Compute sample variance | Σ(xᵢ−x̄)² / n−1 |
| Interpret std deviation | avg distance from mean |
| Detect outliers with IQR | Q1−1.5·IQR rule |
| Inference | Key point |
|---|---|
| Interpret z-score | (x − μ) / σ |
| State H₀ and H₁ | null vs alternative |
| Make p-value decision | p ≤ α → reject H₀ |
| Build a 95% CI | x̄ ± 1.96 · SE |
| Correlation & Power | Key point |
|---|---|
| Pearson r range | −1 to +1 |
| Correlation ≠ causation | check confounders |
| Effect size (Cohen's d) | 0.2 / 0.5 / 0.8 |
| Desired power | 1−β ≥ 0.80 |
Next up → Sheet 2: Probability ·
Bayes' theorem · distributions · expected value · conditional probability · Bayesian vs frequentist