Introduction
A hypothesis test asks whether data provide enough evidence to reject an assumption. You start by assuming nothing has changed (the null hypothesis ), work out how likely your observed result would be under that assumption, and reject only if the result would be very unlikely. This topic covers one- and two-tailed tests for a binomial proportion, critical regions, testing the mean of a normal distribution, and testing a correlation coefficient.
Why it matters
A drug company claims a new treatment works better than the old one. A coin seems to land heads too often. A factory wonders whether a machine has drifted. Each needs a fair way to decide when a difference is real and not just chance. Hypothesis testing is the standard method in science and medicine.
Intuitive explanation
is like the presumption of innocence. The data are the evidence. You only "convict" (reject ) if the evidence would be really surprising were true. If the evidence is not strong enough, you do not conclude is true: you just say there is insufficient evidence to reject it.
A 5% significance level means you reject if a result at least this extreme would happen less than 5% of the time under .
Formal definitions
- Null hypothesis : the parameter has its assumed value, e.g. .
- Alternative hypothesis : what you suspect, e.g. (one-tailed) or (two-tailed).
- Test statistic: the value calculated from the sample, used to decide.
- -value: the probability, under , of a result at least as extreme as the one observed.
- Critical region: the set of values of the test statistic that lead to rejecting . Its boundary is the critical value.
- Actual significance level: the probability of the test statistic falling in the critical region when is true.
Notation
- Hypotheses are always about a population parameter (, or ), never a sample statistic.
- for the mean of a sample of size from .
- is the sample correlation coefficient; the population one.
The procedure
- State and , defining the parameter.
- State the distribution of the test statistic under .
- Calculate the -value (or find the critical region).
- Compare with the significance level. In a two-tailed test, compare each tail with half the level.
- Conclude in context, non-assertively: "There is sufficient evidence at the 5% level to suggest that..."
Key results
If then the mean of a random sample of size satisfies , so .
For , compare (or , for a one-tailed test) with the critical value from tables for the sample size and significance level.
Why the sample mean varies less
Individual values scatter around with standard deviation . In an average of values, high and low values partly cancel. The spread of the average shrinks to : four times the data halves the spread. That is why larger samples detect smaller effects.
Let be independent with mean and variance . By linearity, . Independence makes the covariances vanish, so
If the are normal, so is any linear combination of them (a property of the normal distribution, best proved with moment generating functions), so exactly. For other distributions the central limit theorem makes this approximately true for large .
∎For a continuous statistic the -value is uniform on under (Q51), so exactly. For a discrete statistic the rejection set is a tail whose probability is the -value of its boundary point, which is at most (Q52). Either way, "reject when " and "reject when the statistic is in the critical region" are the same rule.
∎Methods
For an upper-tail test at 5%, find the smallest with . For a lower tail, the largest with . Write both probabilities either side of the boundary to justify your choice.
Never say " is true" or "this proves". Say whether there is (or is not) sufficient evidence, and translate back into the context of the question.
Examples
, , , observed . : reject at 5%.
The Worked examples tab has full model answers in exam format.
Common mistakes
The -value is (or ), not the probability of exactly the observed value.
At the 5% level, each tail is compared with 2.5%.
Write , not or "".
"There is evidence to suggest the coin is biased", not "the coin is biased".
Applications
- Clinical trials: whether a treatment improves recovery rates.
- Manufacturing: whether a machine's mean output has changed.
- Science: whether two variables are genuinely correlated.
Connections
- Distributions: binomial and normal probabilities.
- Correlation: the correlation coefficient .
- Sampling: tests assume a random sample.
Summary
- (assume no change) and (one- or two-tailed), about a population parameter.
- Binomial: compare or with the significance level (halve for two tails).
- Critical region: values leading to rejection; actual significance is its probability under .
- Normal mean: .
- Conclude in context and non-assertively.
Worked examples
Try each one yourself first, then open the solution.
A spinner is supposed to land on red with probability . Ali thinks it lands on red more often. In 20 spins it lands on red 10 times. Test Ali's claim at the 5% level.
Show the solution
- 1Hypotheses
Let be the probability of red. , .
- 2Distribution under
.
- 3-value
.
- 4Compare
, so reject .
- 5Conclusion in context
There is sufficient evidence at the 5% level to suggest the spinner lands on red more often than 30% of the time.
Reject : evidence that
. Find the critical region for a test of against at the 5% level, and the actual significance level.
Show the solution
- 1Lower tail probabilities
, .
- 2Choose the boundary
but .
- 3Critical region
; actual significance level (2.94%).
; actual significance
A coin is tossed 30 times to test whether it is fair, at the 5% level. Find the critical region.
Show the solution
- 1Hypotheses
, . Each tail at .
- 2Lower tail
, : lower region .
- 3Upper tail
By symmetry, : upper region .
- 4Critical region
or . Actual significance .
or
Bags of flour have masses grams, with supposed to be . A sample of 16 bags has mean g. Test at the 5% level whether the mean has increased.
Show the solution
- 1Hypotheses
, .
- 2Sampling distribution
Under , , standard deviation .
- 3-value
; .
- 4Conclusion
: reject . There is evidence that the mean mass has increased.
Reject ()
For 12 pairs of data, . Test at the 5% level whether there is positive correlation. (Critical value for , one-tailed 5%: .)
Show the solution
- 1Hypotheses
, .
- 2Compare
, so lies in the critical region.
- 3Conclusion
Reject : there is evidence of positive correlation in the population.
Reject
University-level ideas and the deeper mathematics behind this topic. Not needed for exams, but this is where the subject really opens up.
Optimal tests: the Neyman–Pearson lemma (university)
A test makes two kinds of mistake. A Type I error (rejecting a true ) has probability , the size. A Type II error (keeping a false ) has probability , where is the power. Shrinking one usually grows the other, so the classical approach, due to Neyman and Pearson (1933), is to fix the size and then make the power as large as possible.
A (possibly randomised) test is a function : the probability of rejecting when the data are . Its size is and its power is , where and are expectations under the two hypotheses. An ordinary test has taking only the values and ; the randomised test of Q58 has .
Let and be the densities (or probability functions) under simple hypotheses and . For , let
with and chosen so that . Then every test with has .
For every , the product : where , ; where , ; and where they are equal the product is . Integrating (or summing) over :
The proof is a single inequality, yet it settles the question completely: reject where the likelihood ratio is largest. Think of it as a budget problem. Each point "costs" of the size budget and "earns" of power; the best buys are those with the highest earnings per unit cost.
A family has a monotone likelihood ratio in a statistic if, for , the ratio is an increasing function of .
If has a monotone likelihood ratio in , then the test "reject when " (randomising at if needed), with size at , is uniformly most powerful for against .
The normal mean with known has a monotone likelihood ratio in (Q53), and the binomial has one in , since
increases in when . So the one-tailed tests of this topic are the best possible tests. Karlin–Rubin also explains why the boundary value goes in : the power function is increasing (Q56), so the largest Type I error over occurs at .
For , the most powerful test against rejects for large , and against for small . No single test can be best against both, so the symmetric two-tailed test is a compromise. It is the uniformly most powerful unbiased test: the best among tests whose power is never below .
Likelihood ratio tests, confidence intervals and the correlation test (university)
Most real hypotheses are composite: the null leaves some parameters free (an unknown variance, say). The general recipe replaces each simple likelihood by its maximum.
For inside a larger model ,
and is rejected when is small.
Under regularity conditions, if is true then
where is the number of parameters fixed by .
Write and let be the maximum likelihood estimate. In one dimension with , a Taylor expansion about , where , gives
Asymptotically and , where is the Fisher information. So with , which is .
∎For with free, the maximised likelihoods give , where and . Hence
so the likelihood ratio test is Student's -test, which is exact for every (Gosset, 1908).
Suppose that for each there is a test of of size with acceptance region . Then
is a confidence set, since . Conversely, a confidence interval gives a test: reject when it lies outside the interval.
For instance, the two-tailed test of Q28 accepts exactly when lies within of it. Turned round, is the confidence interval for : the values that the data do not reject.
For bivariate normal data with , the statistic has a distribution. Equivalently, has density proportional to on , and inverting gives the critical values (Q57). For the distribution of is skewed. Fisher's transformation
makes it nearly normal, which gives tests of and confidence intervals for .
The correlation test also needs care with its assumptions. The tables assume a random sample from a bivariate normal population; with outliers or curved relationships, Spearman's rank correlation (which uses only the order of the data) is safer.
What p-values do not tell you: Bayes, multiple testing and replication (university)
A -value is . Almost every misuse of hypothesis testing comes from treating it as something else.
With prior probability , the posterior odds against after seeing data are
where is the Bayes factor.
The -value is neither the Bayes factor nor the posterior probability. Q50 shows the gap directly: with of nulls true, tests with power give a false discovery rate of .
Test against with data , and suppose is fixed at , so for every . The Bayes factor in favour of is
So with a large enough sample, a result "significant at " can be strong evidence for . The reason: with huge , a just-significant is tiny, and such a small effect is better explained by than by a typical under . Fixed significance levels ignore sample size; Bayes factors do not.
When tests are run, let be the number of true nulls that are rejected and the total number of rejections.
- Family-wise error rate: . Bonferroni (each test at ) keeps it at most under any dependence (Q59).
- False discovery rate: , the expected fraction of discoveries that are false.
Order the -values , let be the largest with , and reject the hypotheses with the smallest -values. If the tests are independent, , where is the number of true nulls.
Bonferroni suits a handful of tests where any false claim is costly. Benjamini–Hochberg suits screening thousands of genes or features, where some false leads are acceptable but they should be a controlled fraction of the discoveries.
In Q60, testing after tosses and again after raised the true size from to . With unlimited looks the law of the iterated logarithm guarantees that eventually exceeds , so "keep collecting until " rejects a true with probability . Choosing the tail after seeing the data (Q47), dropping awkward observations, or trying several analyses and reporting the best are the same mistake in disguise. Sequential methods (Wald's sequential probability ratio test, alpha-spending in clinical trials) handle repeated looks properly by planning them in advance.
These issues are behind the replication crisis: in 2015 a large collaboration repeated published psychology experiments and obtained significant results in only about of them. The response includes pre-registration (fixing hypotheses and analysis before collecting data), reporting effect sizes with confidence intervals rather than bare -values, larger samples (Q55), and in some fields stricter thresholds such as , or the rule () used in particle physics for the Higgs boson.
Why does this work?
The significance level is the probability of rejecting when it is true (a Type I error). If you look at the data first and then choose the test or the level that gives a "significant" result, that probability is no longer what you claim. Deciding in advance keeps the test honest.
Beyond the syllabus
Mathematical curiosities
If 20 independent true null hypotheses are each tested at 5%, the chance that at least one is "significant" is . Testing many hypotheses and reporting only the significant ones (-hacking) has led to many published results that later failed to replicate.