Skip to content
ml-recall

Topic notes

Statistics & Estimation

Collecting and summarising data, sampling distributions, confidence intervals and hypothesis tests, plus estimation for ML — maximum likelihood, bias and MSE, Bayesian posteriors and MCMC.

4-min read AI-checked

Practise 158 questions Take a test

Key ideas

Collecting data1. A parameter describes the population, a statistic the sample.

Describing data. Mean (pulled by outliers; raising one of nn values by cc raises the mean by c/nc/n), median, quartiles, SD. Adding a constant shifts the mean but not the SD; multiplying scales both. z=(x−μ)/σz=(x-\mu)/\sigma counts SDs from the mean2. Charts: histogram (distribution of one numeric variable — more bins, finer detail), KDE (smooth estimate of it), bar chart (categories), line chart (trends over time), pie or waffle chart (parts of a whole), scatter plot (two numeric variables; colour, size or shape add a third), facets (one panel per value of a variable). Truncated or reversed axes and too many pie slices mislead.

Normal model2: 68–95–99.7% within 1, 2, 3 SDs. Key quantiles: z0.80=0.842z_{0.80}=0.842, z0.90=1.282z_{0.90}=1.282, z0.95=1.645z_{0.95}=1.645, z0.975=1.96z_{0.975}=1.96, z0.99=2.326z_{0.99}=2.326, z0.995=2.576z_{0.995}=2.576.

Sampling distribution and CLT. A statistic varies from sample to sample; its distribution over all samples of size nn is the sampling distribution, and its SD is the standard error2. Xˉ\bar X has mean μ\mu and SE σ/n\sigma/\sqrt n; by the CLT it is approximately normal when the observations are independent and nn is large, whatever the population's shape (finite variance) 2. With small nn from a skewed population it is still skewed.

Confidence intervals. estimate ± critical value × SE. "95% confidence" describes the procedure: about 95% of intervals built this way contain the parameter; it is not a 95% probability that this particular interval does3. The margin of error is z∗×z^*\timesSE, about 2×2\timesSE at 95%2. Higher confidence → wider; four times the data → half the width. The width scales with z∗z^*: 95% instead of 90% multiplies it by 1.96/1.645≈1.191.96/1.645\approx1.19.

Hypothesis tests3: H0H_0 (no effect) vs HaH_a. The p-value is the probability, computed assuming H0H_0, of a test statistic at least as extreme as the one observed; reject when p≤αp\le\alpha.

H0H_0 true H0H_0 false
reject H0H_0 Type I error, probability α\alpha correct; probability = power =1−β=1-\beta
keep H0H_0 correct Type II error, probability β\beta

β\beta cannot be computed from α\alpha alone (it depends on the true effect and nn); more data raises power at fixed α\alpha3. Use a tt distribution with n−1n-1 df when σ\sigma is estimated — heavier tails, approaching the normal as df grows3. Chi-square test of independence on an r×cr\times c table: df =(r−1)(c−1)=(r-1)(c-1), expected counts at least 5 in every cell8; larger df shift the distribution right, so the critical value grows with df8. Correlation r∈[−1,1]r\in[-1,1] has no units; R2=r2R^2=r^2 is the share of the variation in yy explained by the least-squares line7, so it grows with the square of rr (r=0.5r=0.5 explains 25%).

Estimation for ML. Maximum likelihood picks the parameters that make the data most probable; in practice minimise the negative log-likelihood (sums instead of products, no underflow)4. Gaussian: μ^=xˉ\hat\mu=\bar x, σ^2=1n∑(xi−xˉ)2\hat\sigma^2=\frac1n\sum(x_i-\bar x)^2 (biased; 1n−1\frac1{n-1} is unbiased). An estimator's MSE = bias² + variance, so a biased estimator with small variance can have a lower MSE than an unbiased one3. Bayesians put a prior distribution on parameters; frequentists do not. Beta(a,ba,b) prior + kk successes in nn Bernoulli trials → Beta(a+ka+k, b+n−kb+n-k) posterior, predictive P(xnew=1)=a+ka+b+nP(x_{\text{new}}=1)=\frac{a+k}{a+b+n}5.

MCMC. Random-walk Metropolis–Hastings proposes θ∗\theta^* near θ\theta and accepts with probability min⁡(1,p∗(θ∗)/p∗(θ))\min(1,p^*(\theta^*)/p^*(\theta)), so the normalising constant is never needed6. Discard the early burn-in samples, which still reflect the start point. Tiny proposals: almost all accepted but the chain crawls; huge proposals: most rejected, long flat stretches. Correlated samples carry less information (smaller effective sample size)6.

Formulas

SE(xˉ)=σn,SE(p^)=p^(1−p^)n,n≥(z∗ME)2p(1−p)\text{SE}(\bar x)=\frac{\sigma}{\sqrt n},\qquad \text{SE}(\hat p)=\sqrt{\frac{\hat p(1-\hat p)}{n}},\qquad n\ge\Big(\frac{z^*}{\text{ME}}\Big)^2 p(1-p) MSE(θ^)=(E[θ^]−θ)2+Var(θ^)\text{MSE}(\hat\theta)=\big(E[\hat\theta]-\theta\big)^2+\mathrm{Var}(\hat\theta)

Worked example

n=100n=100, xˉ=52\bar x=52, known σ=10\sigma=10: SE =10/100=1=10/\sqrt{100}=1; 95% CI 52±1.96=[50.04, 53.96]52\pm1.96=[50.04,\,53.96]. Test H0:μ=50H_0:\mu=50: z=(52−50)/1=2z=(52-50)/1=2, two-sided p≈0.046<0.05p\approx0.046<0.05 → reject; consistently, 50 lies outside the 95% CI. MLE for data {2,4,4,6}\{2,4,4,6\} under a Gaussian: μ^=4\hat\mu=4, σ^2=8/4=2\hat\sigma^2=8/4=2 (unbiased: 8/38/3). Uniform Beta(1, 1) prior, 6 heads in 8 tosses → Beta(7, 3), predictive 7/10=0.77/10=0.7 (MLE 0.750.75).

Common pitfalls

References

  1. OpenIntro, Introduction to Modern Statistics (2nd ed.), Ch. 2 Study design — Sec. 2.1 Sampling principles and strategies (Four sampling methods); 2.2 Experiments (Principles of experimental design; Reducing bias in human experiments); 2.3 Observational studies
  2. OpenIntro, Introduction to Modern Statistics (2nd ed.), Ch. 13 Inference with mathematical models — Sec. 13.1 Central Limit Theorem; 13.2 Normal Distribution (Standardizing with Z scores); 13.3 Quantifying the variability of a statistic (68-95-99.7 rule; Standard error; Margin of error); 13.6.3 Interpreting confidence intervals
  3. Dive into Deep Learning — Sec. 22.10.1 Evaluating and Comparing Estimators; 22.10.2 Conducting Hypothesis Tests; 22.10.3 Constructing Confidence Intervals
  4. Dive into Deep Learning — Sec. 22.7.1 The Maximum Likelihood Principle; 22.7.2 Numerical Optimization and the Negative Log-Likelihood; 22.7.3 Maximum Likelihood for Continuous Variables
  5. Wikipedia: Conjugate prior — Example; Interpretations (Pseudo-observations); Table of conjugate distributions
  6. Wikipedia: Metropolis–Hastings algorithm — Description; Step-by-step instructions
  7. OpenIntro, Introduction to Modern Statistics (2nd ed.), Ch. 7 Linear regression with a single predictor — Sec. 7.1 Fitting a line, residuals, and correlation (Describing linear relationships with correlation); 7.2 Least squares regression (Describing the strength of a fit)
  8. OpenIntro, Introduction to Modern Statistics (2nd ed.), Ch. 18 Inference for two-way tables — Sec. 18.1 Randomization test of independence (Expected counts in two-way tables); 18.2 Mathematical model for test of independence (degrees of freedom; conditions)