Sampling Distributions and Inference: CLT, the t and Chi-Squared Distributions, Confidence Intervals and the z, t and Chi-Squared Tests

The last third of Section 1 of the Data Science and AI paper is inference: the central limit theorem, the t-distribution and the chi-squared distribution, the confidence interval, and the z-test, t-test and chi-squared test. The previous chapter fixed the probability; this one turns it into a procedure for deciding from a sample. The whole of it rests on one statement: the sample mean of n independent draws has mean μ and standard error σ/√n, and for large n is approximately normal whatever the underlying distribution — the central limit theorem. If σ is known the standardised mean is standard normal; if it must be estimated by s, the extra uncertainty makes it a t-distribution with n − 1 degrees of freedom, with heavier tails; and a sum of squared standard normals is chi-squared, which is the distribution of variances and of count-based statistics. A confidence interval is estimate ± critical value × standard error; a test compares the same standardised statistic to the same critical values. Every critical value and statistic below was computed by program and checked against standard table entries: t₀.₉₇₅ with 9 degrees of freedom is 2.262, χ²₀.₉₅ with 5 is 11.070, and a 95% interval for n = 16, x̄ = 52, s = 8 is (47.74, 56.26).
Overview

The Central Limit Theorem and the Standard Error

1 min read

Let X₁, …, X_n be independent with the same mean μ and variance σ². The sample mean X̄ has E[X̄] = μ and Var(X̄) = σ²/n, so its standard error is σ/√n — it falls like 1/√n, so quadrupling the sample halves the error. The central limit theorem: as n grows, (X̄ − μ)/(σ/√n) → N(0, 1) in distribution, whatever the shape of the original distribution (provided the variance is finite). A rule of thumb is n ≥ 30, sooner for symmetric distributions and later for heavily skewed ones. The same holds for the sum: S_n ≈ N(nμ, nσ²). Example: scores with mean 50 and SD 10, a sample of n = 64: SE = 10/√64 = 1.25; P(X̄ > 52) = P(Z > (52 − 50)/1.25) = P(Z > 1.60) = 0.0548. For a binomial count, the CLT is the normal approximation: Bin(n, p) ≈ N(np, np(1 − p)), good when np and n(1 − p) both exceed about 5–10, with a continuity correction of ±0.5.

Let X₁, …, X_n be independent with the same mean μ and variance σ². The sample mean X̄ has E[X̄] = μ and Var(X̄) = σ²/n, so its standard error is σ/√n — it falls like 1/√n, so quadrupling…

The t and Chi-Squared Distributions

1 min read · 1 part

Chi-squared. If Z₁, …, Z_k are independent standard normals, χ²_k = ΣZ_i² has mean k and variance 2k and is right-skewed, approaching normal as k grows. For a normal sample, (n − 1)S²/σ² ~ χ²_(n−1) — the distribution of the sample variance. Student's t. If Z is standard normal and V ~ χ²_ν independent of Z, then T = Z/√(V/ν) has the t-distribution with ν degrees of freedom; in practice T = (X̄ − μ)/(S/√n) ~ t_(n−1) for a normal sample. It is symmetric about 0 like the normal but with heavier tails, variance ν/(ν − 2) for ν > 2 (1.667 for ν = 5), and tends to N(0, 1) as ν → ∞. Heavier tails mean larger critical values: two-sided 5% points are t₀.₉₇₅ = 2.776 (4 d.f.), 2.262 (9), 2.131 (15), 2.045 (29), tending to z = 1.960. Chi-squared upper 5% points: 3.841 (1 d.f.), 7.815 (3), 11.070 (5), 16.919 (9).

DistributionArises asMean / variance
Standard normal Z(X̄ − μ)/(σ/√n), σ known0 / 1
t with ν d.f.(X̄ − μ)/(S/√n), σ estimated0 / ν/(ν − 2)
χ² with k d.f.ΣZ_i², and (n − 1)S²/σ²k / 2k

Chi-squared. If Z₁, …, Z_k are independent standard normals, χ²_k = ΣZ_i² has mean k and variance 2k and is right-skewed, approaching normal as k grows. For a normal sample, (n − 1)S²/σ² ~…

Confidence Intervals

1 min read

A 100(1 − α)% confidence interval for a mean is x̄ ± (critical value) × (standard error): with σ known, x̄ ± z_(α/2) σ/√n; with σ unknown, x̄ ± t_(α/2, n−1) s/√n. For n = 16, x̄ = 52, s = 8: t₀.₉₇₅ with 15 d.f. = 2.131, half-width = 2.131 × 8/√16 = 4.263, so the 95% interval is (47.74, 56.26). If σ = 8 were known, the half-width would use z = 1.960 and shrink to 3.920 — the price of estimating σ is a wider interval. Reading it correctly: the 95% describes the procedure — in repeated sampling 95% of intervals built this way cover the true μ. It is not "a 95% probability that μ lies in this particular interval", because μ is fixed and the interval is the random thing. Width grows with σ and with the confidence level, and shrinks with √n. Sample size for margin m: n = (z σ/m)², rounded up: for σ = 10 and m = 2 at 95%, n = 97. Interval for a proportion: p̂ ± z √(p̂(1 − p̂)/n).

A 100(1 − α)% confidence interval for a mean is x̄ ± (critical value) × (standard error): with σ known, x̄ ± z_(α/2) σ/√n; with σ unknown, x̄ ± t_(α/2, n−1) s/√n. For n = 16, x̄ = 52, s =…

Hypothesis Tests: z, t and Chi-Squared

3 min read · 5 parts

Framework. State H₀ (the null, e.g. μ = μ₀) and H₁; pick a significance level α = P(reject H₀ | H₀ true), the Type I error; compute a test statistic whose distribution under H₀ is known; reject if it lies in the critical region, equivalently if the p-value (the probability under H₀ of a result at least this extreme) is below α. Type II error β = P(fail to reject | H₁ true) and power = 1 − β; for a fixed n, lowering α raises β, and more data lowers both. z-test for a mean with known σ: Z = (x̄ − μ₀)/(σ/√n). Example: μ₀ = 100, σ = 15, n = 36, x̄ = 104: Z = 1.60; two-sided p = 0.1096 (not significant at 5%; the critical value is 1.96), one-sided p = 0.0548 (significant at 5% only for a one-sided test). One-sample t-test when σ is estimated: T = (x̄ − μ₀)/(s/√n) ~ t_(n−1): n = 9, x̄ = 105, s = 12, μ₀ = 100 gives T = 1.25 against t₀.₉₇₅,₈ = 2.306, p = 0.247 — fail to reject. Two-sample and paired tests follow the same shape (a paired test is a one-sample test on the differences).

Chi-squared tests. Statistic χ² = Σ (O − E)²/E over categories. Goodness of fit: degrees of freedom = (number of categories − 1 − parameters estimated from the data). A die rolled 60 times with counts 5, 8, 9, 8, 10, 20 and expected 10 each gives χ² = 13.4 on 5 d.f., above the 5% point 11.070, p = 0.0199 — reject fairness. Independence in an r × c table: E_ij = (row total × column total)/grand total, d.f. = (r − 1)(c − 1). For the 2 × 2 table [[30, 20], [20, 30]], every expected count is 25 and χ² = 4.00 on 1 d.f. (critical 3.841), p = 0.0455 — borderline-significant at 5%. Variance test: (n − 1)s²/σ₀² ~ χ²_(n−1) under H₀: n = 10, s² = 25, σ₀² = 16 gives χ² = 14.063 on 9 d.f. against 16.919. The chi-squared test needs expected counts of about 5 or more per cell, and it is always an upper-tail test.

⚠️ z or t, and the tail
Use z when σ is known (or n is large and you accept the approximation) and t when σ is estimated from the sample. A "two-sided" question doubles the one-tail probability and uses α/2 in each tail. And "do not reject H₀" is not "H₀ is true": the data were too weak to exclude it. A p-value of 0.04 is not "a 96% chance H₁ is true".
A hypothesis test, step by step
  1. State H₀ and H₁
  2. Pick significance level αType I error
  3. Compute the test statisticDistribution under H₀ known
  4. Reject if p-value < αSame as: in the critical region
z-test vs t-test for a mean
z-test
  • σ known
  • Z = (x̄ − μ₀)/(σ/√n)
  • Two-sided 5% critical value 1.96
t-test
  • σ estimated from the sample
  • T = (x̄ − μ₀)/(s/√n)
  • t with n − 1 d.f.

Framework. State H₀ (the null, e.g. μ = μ₀) and H₁; pick a significance level α = P(reject H₀ | H₀ true), the Type I error; compute a test statistic whose distribution under H₀ is known…

Key takeaways

  • X̄ has mean μ and standard error σ/√n; the CLT makes (X̄ − μ)/(σ/√n) approximately N(0, 1) for large n whatever the distribution; Bin(n, p) ≈ N(np, np(1 − p)).
  • t = (X̄ − μ)/(S/√n) ~ t_(n−1), heavier-tailed than normal (variance ν/(ν − 2)); χ²_k = ΣZ² has mean k and variance 2k; (n − 1)S²/σ² ~ χ²_(n−1).
  • CI = estimate ± critical value × SE; σ unknown means t with n − 1 d.f.; the 95% describes the procedure, not the probability that μ is in one given interval; n = (zσ/m)².
  • Tests: α is the Type I error, β the Type II, power = 1 − β; z-test Z = (x̄ − μ₀)/(σ/√n), t-test with s and n − 1 d.f.; reject when |statistic| exceeds the critical value or p < α.
  • Chi-squared: χ² = Σ(O − E)²/E; goodness of fit has k − 1 − (estimated parameters) d.f., an r × c independence table has (r − 1)(c − 1); it is an upper-tail test and needs expected counts of about 5.

Practice questions (24)

Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.

  1. The standard error of the sample mean of n independent observations with standard deviation σ is:

    1. σ/n
    2. σ/√n
    3. σ²/n
    4. σ√n
    Show answer

    Answer: B — σ/√n

    Var(X̄) = σ²/n, so its standard deviation is σ/√n. σ²/n is the variance, not the standard error; quadrupling n only halves the error.
  2. Scores have mean 50 and SD 10. For a sample of n = 64, P(sample mean > 52) is nearest to:

    1. 0.159
    2. 0.5
    3. 0.421
    4. 0.055
    Show answer

    Answer: D — 0.055

    SE = 10/8 = 1.25, z = (52 − 50)/1.25 = 1.60, upper tail = 0.0548. The 0.421 option wrongly uses SE = 10 (z = 0.2) and 0.159 treats the 64 as 1.
  3. Compared with the standard normal, the t-distribution with few degrees of freedom has:

    1. lighter tails and smaller critical values
    2. heavier tails and larger critical values
    3. the same critical values
    4. a non-zero mean
    Show answer

    Answer: B — heavier tails and larger critical values

    Estimating σ by s adds uncertainty, fattening the tails: t₀.₉₇₅ is 2.776 for 4 d.f. and 2.045 for 29, falling towards 1.960. It is still symmetric about zero.
Show the other 21 questions
  1. A chi-squared random variable with k degrees of freedom has mean and variance:

    1. k and k
    2. 0 and k
    3. 2k and k
    4. k and 2k
    Show answer

    Answer: D — k and 2k

    χ²_k = ΣZ_i² with E[Z²] = 1 and Var(Z²) = E[Z⁴] − 1 = 2, so mean k and variance 2k, summed over k independent terms.
  2. A sample of n = 16 has mean 52 and standard deviation 8 (σ unknown). Find the half-width of the 95% confidence interval for the mean (t₀.₉₇₅ with 15 d.f. = 2.131), to two decimals.

    Numerical answer — type the value.

    Show answer

    Answer: 4.26

    Half-width = t × s/√n = 2.131 × 8/4 = 4.262, so the interval is 52 ± 4.26 = (47.74, 56.26). Using z = 1.96 would give 3.92, too narrow for an estimated σ.
  3. Which is the correct interpretation of a 95% confidence interval (47.7, 56.3) for a population mean?

    1. there is a 95% probability that the true mean lies between 47.7 and 56.3
    2. 95% of intervals built this way from repeated samples would contain the true mean
    3. the sample mean lies in the interval with probability 0.95
    4. 95% of individual observations lie in the interval
    Show answer

    Answer: B — 95% of intervals built this way from repeated samples would contain the true mean

    The population mean is a fixed number; the randomness is in the interval. The 95% is the long-run coverage of the procedure. The interval is also much narrower than the spread of individual observations (which would need s, not s/√n).
  4. A z-test of H₀: μ = 100 uses σ = 15, n = 36 and x̄ = 104. The test statistic and the decision at the 5% two-sided level are:

    1. Z = 1.60; do not reject
    2. Z = 0.27; do not reject
    3. Z = 4.00; reject
    4. Z = 1.60; reject
    Show answer

    Answer: A — Z = 1.60; do not reject

    Z = (104 − 100)/(15/6) = 1.60 < 1.96, two-sided p = 0.1096, so H₀ is not rejected. Z = 4 forgets to divide σ by √n.
  5. In a chi-squared test of independence on a 3 × 4 contingency table, the number of degrees of freedom is:

    1. 6
    2. 11
    3. 7
    4. 12
    Show answer

    Answer: A — 6

    d.f. = (r − 1)(c − 1) = 2 × 3 = 6; the expected counts are fixed by the row and column totals, which removes the other degrees of freedom.
  6. A die is rolled 60 times giving counts 5, 8, 9, 8, 10, 20 for faces 1 to 6. The chi-squared statistic against fairness and the conclusion at 5% (critical value 11.07 on 5 d.f.) are:

    1. 13.4; do not reject
    2. 1.34; do not reject
    3. 6.7; reject
    4. 13.4; reject fairness
    Show answer

    Answer: D — 13.4; reject fairness

    E = 10 each; χ² = (25 + 4 + 1 + 4 + 0 + 100)/10 = 13.4 > 11.07 with p = 0.020, so reject. The face-6 count of 20 contributes most of it.
  7. Daily sensor readings have σ = 18. The standard error of the mean of 81 independent readings is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 2

    SE = σ/√n = 18/9 = 2. Dividing by n instead of √n gives 0.22, the tempting slip.
  8. A model-comparison test declares a difference when in truth the two models perform equally. This mistake is a:

    1. A sampling bias
    2. Type II error (keeping a false null hypothesis)
    3. A lack of power
    4. Type I error (rejecting a true null hypothesis)
    Show answer

    Answer: D — Type I error (rejecting a true null hypothesis)

    Its probability is the significance level α. Failing to reject a false H₀ is a Type II error (probability β), the usual swap.
  9. A one-sample t-test on a sample of 25 observations uses a t-distribution with how many degrees of freedom? ____

    Numerical answer — type the value.

    Show answer

    Answer: 24

    df = n − 1 = 24, one degree lost to estimating the mean. Answering 25 forgets that loss.
  10. For the same sample, raising the confidence level from 95% to 99% makes the confidence interval:

    1. Narrower
    2. Wider
    3. Unchanged in width
    4. Centred on a different point
    Show answer

    Answer: B — Wider

    More confidence needs a larger critical value (2.576 instead of 1.96), so the interval widens around the same centre. "Narrower" is the intuitive but wrong guess that more confidence means more precision.
  11. The p-value of a test is:

    1. The probability that H₀ is true
    2. The probability that H₁ is true
    3. The significance level chosen before the test
    4. The probability, assuming H₀ is true, of a result at least as extreme as the one observed
    Show answer

    Answer: D — The probability, assuming H₀ is true, of a result at least as extreme as the one observed

    The p-value is computed under H₀ and says how surprising the data are. Reading it as the probability that H₀ is true is the most common misinterpretation.
  12. A chi-squared goodness-of-fit test of a die’s fairness uses 6 categories and estimates no parameters. The degrees of freedom are ____.

    Numerical answer — type the value.

    Show answer

    Answer: 5

    df = categories − 1 − parameters estimated = 6 − 1 − 0 = 5, because the counts must sum to n. Answering 6 forgets that constraint.
  13. With known σ = 12 and a sample of n = 36, the half-width of a 95% confidence interval for the mean (z = 1.96), to two decimals, is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 3.92

    Half-width = 1.96 × 12/√36 = 1.96 × 2 = 3.92. Using 12/36 as the standard error gives 0.65, which divides by n instead of √n.
  14. A population has σ = 15. The smallest sample size for which the standard error of the mean is at most 1 is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 225

    15/√n ≤ 1 gives √n ≥ 15, so n ≥ 225 observations. Answering 15 stops at √n and forgets to square it.
  15. Testing H₀: μ = 50 with known σ = 10, a sample of 25 gives x̄ = 53. The z-statistic is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 1.5

    z = (53 − 50)/(10/5) = 1.5, short of 1.96 for a two-sided 5% test. Forgetting √n gives 0.3.
  16. A sample of 16 has mean 105 and standard deviation 10 (σ unknown). The t-statistic for H₀: μ = 100 is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 2

    t = (105 − 100)/(10/4) = 2.0, compared with t on 15 degrees of freedom. Dividing by s alone gives 0.5.
  17. The power of a hypothesis test is:

    1. β, the probability of a Type II error
    2. 1 − α, the confidence level
    3. α, the probability of rejecting a true H₀
    4. 1 − β, the probability of rejecting H₀ when it is false
    Show answer

    Answer: D — 1 − β, the probability of rejecting H₀ when it is false

    Power measures how often a real effect is detected. 1 − α is the probability of correctly retaining a true H₀, the tempting look-alike.
  18. With σ = 10, the minimum sample size for a 95% confidence interval for the mean to have a margin of error of at most 2 (z = 1.96) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 97

    n ≥ (1.96 × 10/2)² = 96.04, so round up to 97. Rounding down to 96 leaves the margin slightly above 2.
  19. A 2 × 2 table of counts has rows (20, 30) and (30, 20). The chi-squared statistic for independence (no continuity correction) is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 4

    All row and column totals are 50 of 100, so every expected count is 25 and each cell adds 5²/25 = 1: χ² = 4 on 1 df, beyond 3.84. Dividing by the observed counts instead gives about 4.17.
  20. S is the sum of 100 independent observations, each with mean 2 and standard deviation 3. Using the central limit theorem, P(S > 230) to three decimals is ____.

    Numerical answer — type the value.

    Show answer

    Answer: 0.159

    E[S] = 200, SD(S) = 3√100 = 30, so z = 1 and P = 0.159. Using SD = 300 (n × σ) or 3 gives far too wide or narrow a spread.
  21. Which of the following statements about sampling and inference are correct? (More than one may be correct.)

    1. The sample mean is approximately normal for large n even if the population is not, provided its variance is finite
    2. About 95% of 95% confidence intervals built this way from repeated samples contain the true mean
    3. Failing to reject H₀ proves that H₀ is true
    4. The t-distribution approaches the standard normal as the degrees of freedom grow
    Show answer

    Answer: A — The sample mean is approximately normal for large n even if the population is not, provided its variance is finite; B — About 95% of 95% confidence intervals built this way from repeated samples contain the true mean; D — The t-distribution approaches the standard normal as the degrees of freedom grow

    The first three are correct. The last is the trap: not rejecting H₀ only means the data are not strong enough evidence against it; the test may simply lack power.