Back to topics
Exam cheatsheet
Skim it 10 minutes before the exam.
0 · Imports
import numpy as np
from scipy import stats
import math1 · 8 functions
| What | Python | MATLAB |
|---|---|---|
| Mean | np.mean(x) | mean(x) |
| Sample sd | np.std(x, ddof=1) | std(x) |
| Sample var | np.var(x, ddof=1) | var(x) |
| Normal CDF | stats.norm.cdf(x, mu, sig) | normcdf(x,mu,sig) |
| Normal quantile | stats.norm.ppf(p) | norminv(p) |
| t quantile | stats.t.ppf(p, df) | tinv(p,df) |
| Binomial CDF | stats.binom.cdf(k, n, p) | binocdf(k,n,p) |
| Poisson CDF | stats.poisson.cdf(k, lam) | poisscdf(k,lam) |
Note ddof=1 — forget it and the whole question cascades. MATLAB defaults correct.
2 · 5 distributions
| Dist | E | Var | Notes |
|---|---|---|---|
| Bin(n,p) | np | np(1−p) | P(X≥k)=1−cdf(k−1) |
| Poi(λ) | λ | λ | λ (equal) · E[Y²]=λ+λ² |
| U(a,b) | (a+b)/2 | (b−a)²/12 | quantile = a+p(b−a) |
| Exp(mean=m) | m | m² | F(t)=1−e^(−t/m) |
| N(μ,σ) | μ | σ² | norm.cdf / ppf |
| pdf f(x)=c/x² | integrate | integrate → F(t)=1−c/t |
3 · 6 key formulas
Square of expectation
for topics 8/11/17/20 (b)
CLT · sum
topics 5, 9
CLT · mean
topics 10, 12, 14
t confidence interval
topics 4, 6, 7, 15
Proportion margin of error
topic 1 · normal ⟺ n·p̂(1−p̂) > 5
Estimators
unbiased ⟺ Σaᵢ=1 · consistent ⟺ Var→0
4 · Solve-back templates
# critical value (sum, right tail α)
L = n*mu + stats.norm.ppf(1-alpha)*np.sqrt(n)*sigma
# critical value (mean, left tail α)
c = mu + stats.norm.ppf(alpha)*sigma/np.sqrt(n) # z is negative
# sample size (one-sided)
z = stats.norm.ppf(alpha)
n = math.ceil( (z*sigma/(c-mu))**2 ) # <- ceil, round up
# sample size (two-sided, total defect rate alpha)
z = stats.norm.ppf(1-alpha/2) # <- alpha/2 !
n = math.ceil( (z*sigma/half_width)**2 )5 · Pre-submit checklist (each has cost marks)
- Did you write ddof=1 ?
- CI uses t.ppf not norm.ppf ? df = n−1 ? quantile (1+γ)/2 ?
- "at least k" = 1 − cdf(k−1) ? (not 1 − cdf(k))
- E[X²] = Var + mean² , not (E[X])² ?
- CLT: sum uses √n·σ , mean uses σ/√n — not swapped?
- Solve-back n uses ceil ? two-sided uses α/2 ?
- Proportion normality via n·p̂(1−p̂)>5 , not n>30 ?
- Answer ≥3 dp ? rounded when integer required ?