Hypothesis Testing Framework
A pharmaceutical company has a new drug. Does it actually lower blood pressure more than a placebo? Or could the observed improvement be explained by chance? This is the central question of hypothesis testing. It is one of the two great pillars of statistical inference, alongside estimation. Confidence Intervals: Concept and Construction asks "what is the value of this parameter." Hypothesis testing instead asks a sharper, binary question. Is this specific claim about the parameter consistent with the data? Or should we reject it? The framework matters because science, medicine, engineering, and law all run on decisions made under uncertainty. Hypothesis testing is the formal machine that turns "the data look suggestive" into a decision procedure. That procedure has quantified error rates. It forces the analyst to commit, in advance, to what would count as evidence against a claim. It also requires stating honestly how often such a procedure would be wrong, even when used correctly. This discipline — deciding the rule before seeing the outcome — is what separates statistical inference from post-hoc storytelling. The big picture is a courtroom analogy formalized with probability. There is a default position, the null hypothesis. It is presumed true until the data provide sufficiently strong evidence against it. This is exactly as a defendant is presumed innocent. There is a competing claim, the alternative hypothesis, which the data must convince us to prefer. A test statistic condenses the sample into one number. A rejection region specifies which values of that number count as "sufficiently strong evidence." The two ways the procedure can err are quantified and traded off against each other. These are convicting the innocent (Type I error) and acquitting the guilty (Type II error). This article builds the full architecture. It covers the formal definitions of hypotheses, test statistics, and rejection regions. It explains the precise meanings of significance level and power. It presents the fundamental theorem connecting rejection regions to error probabilities. It also includes two complete worked examples with numerically distinct, asymmetric inputs. It closes by pointing toward the machinery that makes this framework operational in practice. That machinery includes The Neyman-Pearson Lemma, p-values, and the standard named tests.
- A hypothesis test decides between a null hypothesis and an alternative using sample data and a fixed decision rule.
- A test statistic is a function of the data; a rejection region is the set of -values that lead to rejecting .
- Type I error (rejecting a true ) has probability , the significance level; Type II error (failing to reject a false ) has probability .
- Power is , the probability of correctly rejecting a false ; it depends on the true parameter value, sample size, and .
- Tests are built by fixing first, then choosing the rejection region to maximize power — this ordering is not optional.
- Every conclusion is conditional on the model assumptions (distribution, independence, sample size) used to derive the sampling distribution of .
- Key idea: a hypothesis test is a pre-committed decision rule whose two error rates are explicitly quantified and traded off, never a post-hoc judgment about "significance."
Where this lives today
Hypothesis testing is the backbone of experimental science: clinical trials use it to decide whether a treatment effect is real, with regulatory agencies mandating pre-registered levels (commonly 0.05 or 0.025 one-sided) precisely to prevent the data-dependent rejection-region abuse illustrated in the counterexample above. In physics, discovery claims (such as the Higgs boson) are framed as hypothesis tests against a "no new physics" null, but with an extremely stringent significance threshold (the "5-sigma" convention) reflecting the cost of false discovery in a field with many simultaneous searches. In engineering and manufacturing, statistical process control charts are built from repeated hypothesis tests that flag when a process mean or variance has shifted out of specification, directly extending the mechanics of Example 1. In machine learning and A/B testing, the same architecture (null: no difference between algorithm variants; test statistic: a standardized difference in conversion rates; rejection region: extreme values) governs decisions about which website design or model to deploy, though at internet scale the framework's dependence on pre-registered rejection regions is often violated by "peeking" at results early, an error structurally identical to the counterexample. In cryptography and statistical hypothesis-testing-based intrusion detection, the same null/alternative structure with controlled false-alarm () and missed-detection () rates underlies anomaly detection systems. The theoretical core developed here — size, power, and the tradeoff between them — sets up directly for The Neyman-Pearson Lemma (optimal tests), the theory of p-values and significance (a continuous-valued summary of the evidence against ), and the standard named procedures gathered under Standard Tests: t, Chi-Squared, and F.
Ask the tutor: How does the choice between a one-sided and two-sided alternative change the critical value and power of a test for the same data?
Let be a random sample from a distribution indexed by an unknown parameter . A statistical hypothesis is a statement that restricts to a subset of . A hypothesis test consists of: 1. A null hypothesis and an alternative hypothesis , where and partition (disjoint, and typically exhaustive: ). 2. A test statistic , a real-valued function of the data whose sampling distribution under is known (exactly or asymptotically). 3. A rejection region (critical region) , a fixed subset of the range of , chosen in advance. The decision rule is:
A hypothesis (a single point) is called simple; a hypothesis with is called composite. The power function of the test is
the probability of rejecting when the true parameter is . For , is the Type I error probability at that ; for , is the power of the test at , and is the Type II error probability at that . The size (or significance level) of the test is
Intuition
Think of the test statistic as a dial with a needle, and the rejection region as a red zone marked on the dial before any data are collected. Once the data arrive, the needle moves to a single position; if it lands in the red zone, we reject . The two hypotheses are not symmetric: is the default, and the burden of proof is on the data to push the needle into the red zone. This asymmetry is deliberate — it mirrors the presumption of innocence, and it means the test is designed to control the more serious error (wrongly abandoning the default) at a fixed, small rate , even before considering how well it detects real effects. Power is the answer to "if is actually true, and specifically true at some value , how likely is the needle to land in the red zone?" This depends on how far is from : values of deep inside 's territory are easy to detect (high power), while values just barely inside are nearly indistinguishable from (power near ). Enlarging the rejection region increases power but also increases — the two error types are locked in a seesaw, and sample size is the lever that lets you push both down simultaneously.
Let be a test statistic with a fully known distribution under a simple null , and let be a rejection region defined by a critical value chosen so that
Assume has a continuous distribution under (so such a exists and is unique), and assume the family is stochastically increasing in : for , under stochastically dominates under , i.e. for every . Then: 1. The test with rejection region has size exactly : when . 2. The power function is non-decreasing in . 3. For fixed , increasing the sample size (holding the family and true fixed, with a consistent, asymptotically normal statistic) drives for every fixed in ; that is, . 4. Among all tests of the simple-vs-simple problem vs () with size at most , no test based on any statistic can have strictly greater power at than the likelihood-ratio test, stated here without proof as the content of The Neyman-Pearson Lemma.
Part 1 (size). By construction , so . For any , stochastic monotonicity gives , so for all under the one-sided composite null formulation, with equality attained at . Hence , proving the test has size exactly .
Part 2 (monotone power). Fix . Stochastic dominance means precisely that for all ; applying this at gives . Since were arbitrary, is non-decreasing.
Part 3 (power to one as ). Suppose is built from a sample of size and is asymptotically normal: under any fixed ,
with strictly increasing in and bounded on compact sets (this holds, for instance, for the sample mean by the Central Limit Theorem, with ). The critical value satisfies where is the upper- standard normal quantile (this uses the continuity assumed for under , ensuring is attained exactly). Fix in . Then
The right-hand threshold equals
Since , the second term is a strictly negative quantity multiplied by , so the whole threshold as . Because the standard normal distribution function satisfies as , and the asymptotic normality gives in the limit (by the Portmanteau theorem applied to convergence in distribution together with the threshold's divergence), we conclude , i.e. .
Part 4 is the Neyman–Pearson lemma; its proof requires the theory of likelihood ratios and most-powerful tests and is developed under The Neyman-Pearson Lemma. It is stated here only to show where this framework leads, not proved, since it needs machinery (the Neyman–Pearson fundamental lemma's variational argument) beyond the error-tradeoff facts established in Parts 1–3. This completes the proof of Parts 1–3, each obtained directly from the definitions of size and power and standard properties of stochastic ordering and normal convergence, without invoking any result that itself depends on this theorem.
∎Worked examples
Example 1: One-sample z-test for a mean, one-sided alternative, asymmetric numbers. A quality-control engineer believes a new machine setting increases the mean fill weight of cereal boxes above the nominal target. Historical process variability is well characterized: fill weights are normally distributed with known standard deviation grams (this is realistic in mature manufacturing lines with long historical records). The target mean is grams. She wants to test
at significance level . She draws boxes and observes a sample mean grams. Step 1 — test statistic. Under , by the sampling distribution of the mean, exactly (normal population, known ). Standardize:
Step 2 — rejection region. This is a one-sided upper test; reject for large . We need with . From the standard normal table, . So . Step 3 — compute the statistic.
Step 4 — decision. Since , falls in the rejection region: reject at level . The data provide statistically significant evidence, at this level, that the true mean fill weight exceeds 500 grams. Step 5 — power at a specific alternative. Suppose the engineer wants to know the power of this test if the machine setting truly shifted the mean to grams. Under ,
so . The rejection region in terms of is . Power is
From the normal table, , so . Thus if the true mean is 502 grams, this test correctly detects the shift about 78.9% of the time; the Type II error rate there is .
Example 2: Two-sided test with a small sample and unknown variance (previewing the t-test), composite null. An agronomist tests whether a new fertilizer changes (in either direction) the mean yield per plot, historically bushels/acre. Population variance is unknown. She samples plots and observes sample mean and sample standard deviation (using the unbiased estimator with in the denominator). She sets and tests
Step 1 — test statistic. Because is unknown and is small, the exact normal-based statistic is unavailable; the standardized statistic using in place of follows a Student distribution with degrees of freedom under (this fact — the exact distribution of under normality of the population — is the content of the t-test, used here only as the known sampling distribution required by the general framework):
Step 2 — rejection region. Two-sided test at splits the error equally into both tails: reject if . From the -table, . So . Step 3 — compute the statistic.
Step 4 — decision. Since , does not fall in the rejection region: we do not reject at level . Despite a seemingly large observed difference (2.4 bushels/acre), the small sample size and moderate variability leave insufficient evidence to conclude the fertilizer changes mean yield. Step 5 — a lesson on error types. This is exactly the situation in which a Type II error is a live risk: if the fertilizer truly raises mean yield by, say, 3 bushels/acre, a sample of only plots may lack the power to detect it reliably. This is precisely why, in practice, one performs power analysis before collecting data — to choose large enough that a scientifically important effect size is detected with high probability, rather than discovering after the fact that the test was underpowered.
The theorem's guarantees — in particular that the test has size exactly — depend critically on the rejection region being fixed before the data are observed, so that the probability computation is a genuine pre-experimental probability. Suppose instead an analyst adopts the following illegitimate procedure: collect the data, compute , and then choose whichever one-sided rejection region ( or , for the same critical value ) happens to contain the observed value, reporting "significant at ." Concretely, take the setup of Example 1 with , , , so under . The analyst's actual rule, described honestly, is: reject whenever , but claim it as a one-sided level- test. Compute the true size of this procedure:
The procedure actually rejects a true 5% of the time, not 2.5% as claimed — the stated size is wrong by a factor of two, purely because the direction of the rejection region was selected using information from the data (the sign of the observed ) rather than fixed beforehand. The theorem's conclusion that "the test has size exactly " fails: the real long-run Type I error rate of this data-dependent procedure is , not . This is a simple, sharp instance of the general danger of choosing a decision rule after inspecting the data — a version of it also underlies the inflation of Type I error rates under multiple testing and "-hacking."
Scope, edge cases & common traps
| Situation | What changes | Common pitfall |
|---|---|---|
| Simple , simple | Power function has one value under ; size and power fully determine the test | Confusing "not rejecting " with "proving true" |
| Composite (e.g. ) | Size is a supremum over , not a single probability | Reporting only as "the" Type I error rate |
| One-sided vs two-sided alternative | Rejection region is one tail vs split into two tails | Choosing the side of a one-sided test after seeing which direction the data lean |
| Unknown variance, small | Test statistic follows , not exactly | Using the normal table's critical values with small and unknown |
| Large | By Theorem Part 3, power for any fixed true | Treating statistical significance at huge as automatically practically important |
| Multiple tests on the same data | Overall Type I error rate compounds across tests | Running many tests and reporting only the "significant" ones (see the counterexample) |
The mathematician behind it
Origins · 1 minJerzy Neyman and how this was discovered
Neyman, working with Egon Pearson at University College London in the late 1920s and 1930s, transformed hypothesis testing from an intuitive practice of "significance" (as used by Ronald Fisher) into a rigorous decision-theoretic framework with two hypotheses, two types of error, and an optimality theory for choosing rejection regions. Their joint 1933 paper introduced the size–power tradeoff and the lemma that bears their names, which identifies the most powerful test for a fixed size in the simple-versus-simple case. Neyman later emigrated to Berkeley, where he built one of the world's leading statistics departments and contributed foundational work on confidence intervals, survey sampling, and the philosophy of frequentist inference.
What exactly is the difference between the null and alternative hypotheses?
The null hypothesis is the default or status-quo claim, typically a statement of "no effect" or "no difference," and it is what the test is designed to potentially reject. The alternative is the claim the researcher often suspects or hopes to support, and it is only adopted if the data provide sufficiently strong evidence against . The asymmetry is structural, not cosmetic: the test's error-rate guarantee () is computed under , while power is computed under ; swapping which hypothesis plays which role changes the entire error-control interpretation of the procedure, even if the mathematical sets and stay the same.
Why must the significance level α be chosen before looking at the data?
Choosing (and hence the rejection region) in advance is what makes the probability statement a valid, pre-experimental guarantee about the long-run behavior of the procedure. If the region or the level is adjusted after seeing the test statistic's value, the actual probability of a false rejection under repeated use of that adjusted procedure is no longer , typically larger, as shown explicitly in the counterexample where a data-dependent choice doubled the true Type I error rate. This principle is why pre-registration of statistical analysis plans is required in clinical trials and increasingly encouraged across experimental science.
Is a small p-value or a rejected null proof that the alternative hypothesis is true?
No. A hypothesis test controls the probability of specific decision errors under repeated sampling; it does not compute the probability that any particular hypothesis is true, which would require a prior distribution over hypotheses (a Bayesian framework, not this one). Rejecting at level means: under a decision rule that would falsely reject a true at most of the time in repeated use, this particular dataset triggered rejection. It is evidence against calibrated by a known false-alarm rate, not a probabilistic certificate on .
How is power related to sample size, and why does this matter for study design?
Under the conditions of the theorem's Part 3, for any fixed true alternative , the power increases toward 1 as the sample size , because the sampling distribution of the test statistic under separates further from its distribution under . This is why researchers perform a power analysis before data collection: given a minimally important effect size, a desired power (commonly 0.80 or 0.90), and a chosen , one can solve for the sample size needed so the study is not doomed to a Type II error from being too small, as nearly happened in Example 2.
What is the relationship between hypothesis testing and confidence intervals?
A two-sided level- test of rejects if and only if falls outside the corresponding -confidence interval for , built from the same test statistic and its sampling distribution as covered in Confidence Intervals: Concept and Construction. This duality means every confidence interval implicitly defines a whole family of hypothesis tests (one for each candidate ), and every family of size- tests, indexed by , can be inverted to produce a -confidence set. The two frameworks answer the same underlying question — how compatible is a parameter value with the data — from complementary angles: estimation (a set of plausible values) versus decision (accept or reject one specific value).
Why can't a rejection region be based on a statistic whose null distribution is unknown?
The entire quantitative content of a hypothesis test — the value of , the location of the critical value, the computation of power — rests on knowing (exactly or via a reliable approximation, such as a large-sample normal or approximation) the distribution of when is true. Without this, the claim "" cannot be verified or even stated, and the procedure reduces to an arbitrary rule with unknown error properties. This is exactly why the derivation of sampling distributions, covered under Sampling Distributions, is a prerequisite: it supplies the null distributions (normal, , chi-squared, ) on which every classical test in Standard Tests: t, Chi-Squared, and F is built.
What is the difference between Type I error, Type II error, and power in plain terms?
Type I error is rejecting a true — a false alarm — and its probability is bounded by , fixed by the analyst before data collection. Type II error is failing to reject a false — a missed detection — and its probability depends on which specific alternative is true, on , and on . Power is , the probability of correctly detecting that alternative; because and trade off against each other for fixed , and both can be driven down simultaneously only by increasing , no single number can describe a test's overall error behavior without specifying which alternative and which sample size are in view.