4.9.21Probability Theory & Statistics

z-test, t-test, chi-squared goodness of fit, F-test

2,054 words9 min readdifficulty · medium

1. The common machinery (WHY everything below works)

WHY a ratio? A raw difference like xˉμ0=3\bar x - \mu_0 = 3 means nothing until you ask "3 compared to what spread?" Dividing by the noise scale standardizes the difference into "number of standard errors," which is comparable across problems.

HOW the Central Limit Theorem powers the z/t tests. For a sample mean of size nn: E[Xˉ]=μ,Var(Xˉ)=σ2n\mathbb{E}[\bar X]=\mu,\qquad \operatorname{Var}(\bar X)=\frac{\sigma^2}{n}

Derivation of the variance (first principles): with i.i.d. XiX_i, Var ⁣(1nXi)=1n2Var(Xi)=1n2nσ2=σ2n.\operatorname{Var}\!\left(\frac1n\sum X_i\right)=\frac1{n^2}\sum\operatorname{Var}(X_i)=\frac{1}{n^2}\,n\sigma^2=\frac{\sigma^2}{n}. So the standard error is SE=σ/n\mathrm{SE}=\sigma/\sqrt n. By the CLT, XˉN(μ,σ2/n)\bar X\approx \mathcal N(\mu,\sigma^2/n), which means Z=Xˉμ0σ/nN(0,1)under H0.Z=\frac{\bar X-\mu_0}{\sigma/\sqrt n}\sim \mathcal N(0,1)\quad\text{under }H_0. This is the z-statistic — and it's the template for the rest.


2. z-test (mean, σ\sigma known)

WHY σ\sigma known is special: the denominator is a fixed constant, so the only randomness is in xˉ\bar x, which is exactly Normal — no extra uncertainty leaks in.


3. t-test (mean, σ\sigma unknown)

WHY divide by n1n-1 (Bessel's correction)? Deviations are taken from xˉ\bar x, not the true μ\mu. The sample is "closest" to its own mean, so (xixˉ)2\sum(x_i-\bar x)^2 systematically underestimates spread. We lose 1 degree of freedom (the constraint (xixˉ)=0\sum(x_i-\bar x)=0), and dividing by n1n-1 makes s2s^2 unbiased: E[s2]=σ2\mathbb E[s^2]=\sigma^2.

Figure — z-test, t-test, chi-squared goodness of fit, F-test

4. Chi-squared goodness of fit

WHY divide by EiE_i (first principles): for counts, the count in a cell is roughly Poisson with mean EiE_i, so its variance is also Ei\approx E_i. Then (OiEi)/Ei(O_i-E_i)/\sqrt{E_i} is a standardized zz-like quantity; squaring and summing ν\nu of them gives a χν2\chi^2_\nu distribution.

WHY ν=k1\nu=k-1 (with no extra params): the counts are constrained by Oi=Ei=n\sum O_i = \sum E_i = n (total fixed), removing 1 degree of freedom from the kk cells.


5. F-test (compare two variances)

WHY this is an F: each s2s^2 is (up to scale) a χ2/ν\chi^2/\nu. The ratio of two independent χ2\chi^2's each divided by their d.f. is, by definition, FF. So the F-test is "two chi-squareds racing."


Recall Explain to a 12-year-old

Imagine you measure something and it looks a bit off from what you expected. Is it really off, or did you just get unlucky? You make a "weirdness score" = how far off you are ÷ how much wobble is normal. If the score is huge, "just unlucky" stops being believable, so you say something real is going on. The z and t scores check if an average is off (t is for when you're not sure how wobbly things are, so it's more cautious). Chi-squared checks if your tally of categories (like die faces) matches what it should. F checks if one thing wobbles more than another. Same trick, different shapes of "what luck can do."


Flashcards

When do you use a z-test vs a t-test for a mean?
z when population σ\sigma is known (or nn huge); t when σ\sigma is unknown and estimated by ss.
Why does the t-distribution have fatter tails than the Normal?
Because ss in the denominator is itself a noisy estimate of σ\sigma, adding extra variability; controlled by ν=n1\nu=n-1.
State the one-sample z-statistic.
Z=(xˉμ0)/(σ/n)N(0,1)Z=(\bar x-\mu_0)/(\sigma/\sqrt n)\sim\mathcal N(0,1) under H0H_0.
Why divide by n1n-1 in the sample variance?
Deviations are from xˉ\bar x not μ\mu; the constraint (xixˉ)=0\sum(x_i-\bar x)=0 removes one d.f., and n1n-1 makes s2s^2 unbiased.
Write the chi-squared GOF statistic and its d.f.
χ2=(OiEi)2/Ei\chi^2=\sum (O_i-E_i)^2/E_i, ν=k1m\nu=k-1-m (mm = estimated parameters).
Why divide each chi-squared term by EiE_i?
Counts are ~Poisson with variance Ei\approx E_i, so (OiEi)/Ei(O_i-E_i)/\sqrt{E_i} is standardized before squaring.
What does the F-test compare and what's its statistic?
Equality of two variances; F=s12/s22Fn11,n21F=s_1^2/s_2^2\sim F_{n_1-1,\,n_2-1}, larger variance on top.
Why is the ratio of variances an F distribution?
Each s2s^2 is (scaled) χ2/ν\chi^2/\nu; ratio of two independent χ2/ν\chi^2/\nu is by definition F.
Rule of thumb for chi-squared GOF validity?
Each expected count Ei5E_i \gtrsim 5; otherwise pool categories.
Does a large p-value prove H0H_0?
No — you only failed to find evidence against it; it doesn't confirm H0H_0.

Connections

  • Central Limit Theorem — justifies Normality of Xˉ\bar X for z/t.
  • Normal Distribution — limiting case of tt as ν\nu\to\infty.
  • Student's t-distribution and Chi-squared Distribution and F-distribution — the reference tails.
  • Degrees of Freedom — counts independent pieces of information.
  • Hypothesis Testing and p-value and Type I and Type II Errors.
  • ANOVA — generalizes the F-test to many group means.
  • Bessel's Correction — the n1n-1 unbiasedness argument.

Concept Map

answered by

standardizes via

derived from

extreme tail rejects

sigma known

sigma estimated

reference dist

reference dist

counts vs expected

reference dist

ratio of variances

reference dist

Is difference real or noise?

Test statistic = signal / noise

Standard error = sigma / sqrt n

Central Limit Theorem

Reject H0

z-test on a mean

t-test on a mean

Normal N 0,1

Student t

chi-squared GOF

chi-squared dist

F-test

F distribution

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, in chaaron tests ka core idea ek hi hai: hum ek "weirdness score" banate hain jo hota hai (jo difference dikha) divided by (jitna noise normally expect karte hain). Agar yeh score bahut bada ho jaye, matlab "sirf luck se hua hoga" wali kahani believable nahi rehti, to hum H0H_0 ko reject kar dete hain. Bas itni si baat hai — fark sirf yeh hai ki kya compare kar rahe ho aur reference distribution kaunsa hai.

z-test tab jab tum mean check kar rahe ho aur population ka σ\sigma already pata ho — denominator fixed hai, to score seedha Normal N(0,1)\mathcal N(0,1) follow karta hai. t-test tab jab σ\sigma pata nahi, to tum ss (sample SD) se estimate karte ho. Lekin ss khud noisy hai, isliye extra uncertainty aati hai aur distribution thoda fat-tailed ho jata hai — yeh hai Student's tt, jiska shape degrees of freedom ν=n1\nu=n-1 pe depend karta hai. Chhote sample mein zyada cautious rehna padta hai (1.96 ki jagah 2.78 type critical value).

Chi-squared goodness of fit categories ke liye hai: observed count OiO_i vs expected EiE_i. Har cell ka contribution (OiEi)2/Ei(O_i-E_i)^2/E_i — divide EiE_i se isliye kyunki count ki variance bhi lagbhag EiE_i hoti hai (Poisson logic). Sab add karo; bada total matlab model fit nahi ho raha. F-test do variances ka ratio s12/s22s_1^2/s_2^2 leta hai — agar dono truly equal hain to ratio 1 ke aaspaas hona chahiye; door chala gaya to variances different hain.

Yaad rakhne ka mantra: Z Sure, T Tries, Chi Counts, F Fights. Aur ek important baat — bada p-value ka matlab yeh nahi ki H0H_0 sach hai; bas tumhe uske against evidence nahi mila. Exam mein degrees of freedom mein estimated parameters subtract karna mat bhoolna!

Go deeper — visual, from zero

Test yourself — Probability Theory & Statistics

Connections