datarekha

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.

9 min read Intermediate GATE DA Lesson 17 of 122

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 true H0 (commonly 0.05). It fixes the critical value (e.g. 1.96 for a two-tailed z at 5%).
  • Decision — reject H0 if the statistic is more extreme than the critical value, or equivalently if the p-value (the chance of data this extreme under H0) 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.

Decision versus realityH0 is TRUEH0 is FALSEReject H0Do not rejectType I error (α)correctcorrectType II error (β)
Type I: convict the innocent (reject a true H0). Type II: acquit the guilty (miss a false H0).

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.

TryTest power

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.

H₀H₁αβpower
H₀ (null)H₁ (alternative)α — Type Iβ — Type IIPower
α (Type I)5.0%false positive rate
β (Type II)74.1%false negative rate
Power (1−β)25.9%true positive rate

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.

Picking the testz-testmean, withσ KNOWN(or large n)z = (x̄−μ₀)/ (σ/√n)t-testmean, withσ UNKNOWN(small n)t = (x̄−μ₀)/ (s/√n)chi-squaredvariance,goodness-of-fit,independenceΣ (O−E)²/ E
Known σ → z. Unknown σ with small n → t. Counts, variance, or a contingency table → chi-squared.

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 = 50 ml; the fill SD is known, σ = 8 ml. A sample of n = 64 bottles averages x̄ = 52 ml. At the 5% level (two-tailed, critical value 1.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 and n).
  • 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

0/6
Q1Recall: what does the significance level α represent?
Q2Trace: a z-test has μ0 = 100, known σ = 15, x̄ = 106, n = 25. Compute the z-statistic. (1 decimal)numerical answer — type a number
Q3Trace: a two-tailed z-test gives |z| = 1.8 at α = 0.05 (critical value 1.96). What is the decision?
Q4Apply: a researcher has n = 10 measurements and does NOT know the population SD. Which test for the mean?
Q5Apply: which statements are TRUE? (select all that apply)select all that apply
Q6Create: a die is rolled 60 times to check if it is fair. You will compare observed face counts against the 10 expected per face. Which test and statistic, and why?

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Practice this in an interview

All questions
What is the difference between the null and alternative hypothesis?

The 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.

What is the difference between one-tailed and two-tailed hypothesis tests, and when is each appropriate?

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.

When do you use a t-test versus a z-test?

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.

What is the chi-square test, and when do you use it?

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.

Related lessons

Explore further

Skip to content