Hypothesis Tests: z-test, t-test & chi-squared
The last lesson estimated a mean; now we want a verdict. A hypothesis test is a courtroom for data: presume the boring default, measure how strange the evidence is, decide — and bound the chance of being wrong. GATE tests recognition: which test fits which situation.
What you'll learn
- Null vs alternative hypothesis, the test statistic, and the significance level α
- When to use a z-test, a t-test, or a chi-squared test
- p-value vs critical value, and Type I vs Type II error
- Forming a z-statistic and making a one-pass reject / do-not-reject decision
Before you start
The last lesson estimated a mean; now we want a verdict. Think of a hypothesis test as a small courtroom. You begin by presuming innocence — the null hypothesis, the boring default that nothing has changed — and then ask: if that were true, how strange would the data we actually saw be? Strange enough, and you reject the presumption. Not strange enough, and you walk away unconvinced. You never prove the null true; you only decide whether the evidence is strong enough to overturn it.
For GATE the bar is mostly recognition: read a scenario, name the right test, write the right statistic. Full derivations are rare, so we keep the depth there.
The framework
- Null hypothesis
H0— the default claim, usually “no effect” or a specific value, likeμ = 50. - Alternative
H1— what you suspect instead, likeμ ≠ 50(two-tailed) orμ > 50(one-tailed). - Test statistic — one number measuring how far the data sits from
H0, in standard-error units. - Significance level
α— the risk you accept of rejecting a trueH0(commonly0.05). It fixes the critical value (e.g.1.96for a two-tailedzat 5%). - Decision — reject
H0if the statistic is more extreme than the critical value, or equivalently if the p-value (the chance of data this extreme underH0) falls belowα.
p-value < α → reject H0 |statistic| > critical value → reject H0
p-value ≥ α → do not reject |statistic| ≤ critical value → do not reject
Two ways to be wrong
A verdict can err in two directions, and the courtroom names them well.
A Type I error is rejecting a true null (convicting the innocent), and its rate is
exactly α. A Type II error is failing to reject a false null (acquitting the
guilty), with rate β; the power 1 − β is the chance of correctly catching a
real effect. Drag the threshold below: slide it to shrink the red Type-I area and the
orange Type-II area grows — you trade one error for the other. But push the effect size
or the sample size up and the two bells separate, so power climbs without spending
any more α. That is why bigger samples make tests more decisive.
Drag the threshold — watch α, β, and power shift
H0 (left curve) and H1 (right curve) overlap. Move the decision line — or adjust effect size and sample size — to see how the error areas change.
Which test? z, t, or chi-squared
This is the choice GATE most wants you to make, and it hinges on what you know and what you are testing.
Use a z-test for a mean when the population σ is known (or n is large
enough that the sample SD is reliable) — the CLT from the last lesson is what justifies
it. Use a t-test when σ is unknown and estimated from the sample as s,
typically with small n; it runs on Student’s t-distribution, whose heavier
tails account for the extra uncertainty of estimating σ, approaching the Normal as
n grows. Use a chi-squared (χ²) test for counts and categories — testing a
variance, a goodness-of-fit, or independence in a contingency table — by summing
(observed − expected)² / expected.
A worked example — a two-tailed z-test
A machine should fill bottles to
μ0 = 50ml; the fill SD is known,σ = 8ml. A sample ofn = 64bottles averagesx̄ = 52ml. At the 5% level (two-tailed, critical value1.96), is the machine off-target?
H0: μ = 50 vs H1: μ ≠ 50 σ known, large n → z-test
standard error = σ/√n = 8/√64 = 8/8 = 1
z = (x̄ − μ0)/(σ/√n) = (52 − 50)/1 = 2.0
compare |z| = 2.0 with the two-tailed 5% critical value 1.96:
2.0 > 1.96 → reject H0
There is significant evidence at the 5% level that the machine is off-target. Note how
close it is, though — at the 1% level the critical value is 2.576, and 2.0 < 2.576,
so you would not reject. The threshold matters.
A question to carry forward
You have now turned data into chances, into summaries, and into verdicts — the whole of the Probability roadmap. The next roadmap leaves randomness behind for the exact world of vectors and matrices. But one word will follow you across the border: independence. Here it meant events that tell you nothing about each other; there it will mean directions that cannot be built from one another. What might independence mean for arrows rather than events?
In one breath
- A test is a courtroom: presume H0 (the boring default), measure how surprising the data is, and reject only if it is extreme enough — you never prove H0.
- Decide by
p-value < α⇔|statistic| > critical value(two-tailed 5% → 1.96; one-tailed 5% → 1.645). - Errors: Type I = reject a true H0 (rate
α); Type II = miss a false H0 (rateβ); power= 1 − β(grows with effect size andn). - Which test: σ known / large n → z; σ unknown / small n → t (heavier tails); counts, variance, goodness-of-fit, independence → χ²
Σ(O−E)²/E. - GATE is recognition: name the test and the right one/two-tailed critical value. z-statistic
= (x̄−μ₀)/(σ/√n).
Practice
Quick check
Practice this in an interview
All questionsThe null hypothesis (H0) is the default claim of no effect or no difference, while the alternative hypothesis (H1) is what you are trying to find evidence for. Hypothesis testing asks whether the observed data is surprising enough under H0 to justify rejecting it in favor of H1.
A two-tailed test rejects H0 when the statistic is extreme in either direction; a one-tailed test rejects only in one pre-specified direction. Two-tailed tests are the default because they guard against effects in both directions; one-tailed tests are valid only when a directional hypothesis is theoretically justified and pre-registered before seeing the data.
Use a z-test when the population standard deviation is known and the sample is large (n >= 30, by convention); use a t-test when the standard deviation must be estimated from the sample, which is almost always the case in practice. For large n the two tests converge, but the t-test is the safe default.
The chi-square test assesses whether observed categorical frequencies differ from expected frequencies (goodness-of-fit) or whether two categorical variables are independent of each other (test of independence). It requires count data, a sufficiently large sample, and expected cell counts of at least 5.