What Is Hypothesis Testing?
Hypothesis testing is a statistical method that uses sample data to decide whether there is enough evidence to reject a claim about a population, called the null hypothesis (H₀).
A hypothesis test turns the data into a test statistic, converts it into a p-value and compares the p-value with a significance level (α) fixed in advance. Ronald A. Fisher introduced significance testing with p-values in the 1920s, and Jerzy Neyman and Egon Pearson added the alternative hypothesis, fixed α and the two error types in 1933. This calculator runs the 3 most common one-sample tests; the Z Test Calculator adds two-sample tests.
The 5 Steps of Hypothesis Testing
To run a hypothesis test, follow 5 steps:
- State the hypotheses: H₀ (no effect) and H₁ (the effect you test for).
- Choose α: usually 0.05, set before collecting data.
- Compute the test statistic: z or t, from the sample.
- Find the p-value (or compare the statistic with the critical value).
- Decide and interpret: reject H₀ when p ≤ α, then state the result in plain words.
Writing the Null and Alternative Hypotheses
The null hypothesis states the "no effect" value with an equals sign, and the alternative hypothesis states the effect with ≠, < or >.
| Claim to test | H₀ | H₁ | Tail |
|---|---|---|---|
| The mean differs from 30 | μ = 30 | μ ≠ 30 | two-tailed |
| The mean is below 30 | μ = 30 | μ < 30 | left-tailed |
| The proportion exceeds 0.5 | p = 0.5 | p > 0.5 | right-tailed |
How to Use the Hypothesis Test Calculator
To use the hypothesis test calculator, follow 4 steps:
- Choose what you test: a mean with σ known (z-test), a mean with σ unknown (t-test) or a proportion (z-test).
- Enter the sample values.
- Enter the hypothesized value and choose the tail.
- Set α.
The flowchart traces the 5 steps with your numbers and lights up the outcome. The decision matrix below it highlights the row for your decision and shows which error that decision could be making.
Which Test Should You Use?
Choose the test from the type of data, the number of groups and whether σ is known:
| Data | One group | Two independent groups | Two related measurements | Three or more groups |
|---|---|---|---|---|
| Mean, σ known | One-sample z-test | Two-sample z-test | Paired z-test | ANOVA |
| Mean, σ unknown | t-test (this page) | Welch t-test | paired t-test | One-way ANOVA |
| Proportion | One-proportion z-test | Two-proportion z-test | McNemar test | Chi-square test |
| Small-sample proportion | Exact binomial test | Fisher's exact test | exact McNemar | Freeman–Halton |
Type I and Type II Errors
A Type I error rejects a true H₀, and a Type II error fails to reject a false H₀.
| H₀ true | H₀ false | |
|---|---|---|
| Reject H₀ | Type I error (probability α) | Correct (power, 1 − β) |
| Fail to reject H₀ | Correct (probability 1 − α) | Type II error (probability β) |
Lowering α from 0.05 to 0.01 cuts Type I errors but raises the chance of a Type II error for the same sample size.
Statistical Power
Statistical power is the probability that a test rejects H₀ when a real effect of a given size exists, 1 − β. Studies usually aim for 80% power. Power rises with a larger sample, a larger effect and a larger α. Plan the sample needed for 80% power with the sample size calculator.
Hypothesis Test Examples
There are 2 worked examples below.
Example 1: Mean, σ Unknown
25 bags of coffee have a mean weight of 31.2 g and s = 4.5 g. The label says 30 g. Does the mean differ?
- HypothesesH₀: μ = 30, H₁: μ ≠ 30
- Standard errorSE = 4.5 / √25 = 0.9
- Test statistict = (31.2 − 30) / 0.9 = 1.333, df = 24
- Critical valuet* = ±2.064
- P-valuep = 0.1949
- DecisionFail to reject H₀: the data do not show a difference from 30 g.
Example 2: Proportion
58 of 100 voters support a policy. Is support above 50%?
- HypothesesH₀: p = 0.5, H₁: p > 0.5
- Standard errorSE = √(0.25 / 100) = 0.05
- Test statisticz = (0.58 − 0.50) / 0.05 = 1.60
- P-valuep = P(Z ≥ 1.60) = 0.0548
- DecisionFail to reject H₀ at α = 0.05; reject at α = 0.10.
FAQs
Why do we say "fail to reject" instead of "accept" H₀?
We say "fail to reject" since a hypothesis test can only show that the data are inconsistent with H₀, not that H₀ is true. A non-significant result can come from a small sample or a small effect. Equivalence tests are the tool for showing that an effect is practically zero.
Can I change α after seeing the results?
No, changing α after seeing the results invalidates the test. Moving α from 0.05 to 0.10 to rescue a p-value of 0.07 raises the false-positive rate. Fix α, the tail and the analysis before collecting data.
What is the difference between Fisher's and Neyman–Pearson's approaches?
Fisher treated the p-value as a continuous measure of evidence, while Neyman and Pearson used a fixed α to make a reject-or-not decision with known error rates. Modern practice mixes the two: researchers fix α and report the exact p-value.
Can hypothesis tests be run on non-random samples?
Hypothesis tests can be calculated on non-random samples, but the p-value no longer describes the population. The math assumes random sampling or random assignment. With a convenience sample, the result applies only to people like those sampled.
How many tests can I run before multiple testing becomes a problem?
Multiple testing becomes a problem from the second test onward, since each test adds a chance of a false positive. 5 tests at α = 0.05 give a 22.6% chance of at least one false positive, and 20 tests give 64.2%. Apply a Bonferroni correction, dividing α by the number of tests.