What a test is allowed to conclude
A hypothesis test is a decision rule with a stated error budget. You specify a default position, compute how surprising the data would be if that default were true, and reject the default when the surprise exceeds a threshold you chose in advance. The output is deliberately narrow: either there is enough evidence to reject the default, or there is not. Nothing in the procedure proves the default true, and nothing in it measures how important a detected effect is.
That narrowness is a feature. Without a formal rule, every difference between two groups looks like a finding, because sample means never match exactly. The test forces you to name the comparison before seeing the data, which is what separates measurement from storytelling. It also forces you to declare an error rate: the significance level is the long-run fraction of times you will reject a true default, and choosing it means deciding how costly false alarms are relative to missed detections in your specific problem.
Writing H0 and H1 so they cannot be confused
The null hypothesis is the claim that the data are generated with no effect present â no difference between groups, no association between variables, a coefficient of exactly zero, a proportion equal to a benchmark. The alternative is everything you would conclude if the null were rejected: a difference in either direction, an association, a non-zero coefficient. Because the null carries the status quo, the burden of proof sits on the alternative, and the data have to be unusually inconsistent with the null before you are allowed to switch positions.
The direction of the alternative determines whether the test is one-sided or two-sided. Two-sided is the default, because it detects effects in both directions and never requires you to commit to a direction before seeing data. A one-sided test is defensible only when the opposite direction is genuinely impossible or genuinely irrelevant and that commitment was made in advance. Switching to a one-sided test after noticing the direction of the result doubles your effective error rate and is one of the most common ways a study's p-value becomes decorative.
| Null is true | Null is false | |
|---|---|---|
| Reject the null | Type I error, probability alpha, a false positive | Power, probability one minus beta, a true positive |
| Fail to reject | Correct retention, a true negative | Type II error, probability beta, a false negative |
The p-value and what it does not say
The p-value is the probability, computed assuming the null is true, of obtaining a test statistic at least as extreme as the one you observed. It measures incompatibility between the data and the null model. Small p-values mean the data would be unusual under the null; they do not measure the size of the effect, the probability that the null is true, or the probability that the result will replicate.
Interpretation bands are conventions rather than laws, but they are useful scaffolding. Below one percent is strong evidence against the null; between one and five percent is conventional; between five and ten percent is weak; above ten percent is little to none. Reporting the exact value is always better than a threshold label, because a p-value of zero point zero four nine and one of zero point five lead to different degrees of scepticism even though only one crosses the line. The p-value also depends on sample size: with a hundred thousand observations, a trivial difference will clear almost any threshold, which is why effect size must accompany it.
Two errors, one dial
Type I and Type II errors trade against each other for a fixed sample size. Lowering the significance level reduces false alarms but makes real effects harder to detect; raising it does the reverse. Increasing the sample size is the only move that improves both at once, because it shrinks the standard error and pulls the two sampling distributions apart relative to their spread. This is why arguments about whether to use zero point zero five instead of zero point zero one are really arguments about the relative cost of a false alarm versus a miss.
The consequences differ sharply by domain. Screening email for spam tolerates false positives because the cost of a missed spam message is low, so the threshold sits permissively. A clinical approval for a toxic drug does not, so the threshold is stringent. In both cases the significance level is a policy choice expressed as a number, and the honest way to present a result is to state the level, the p-value, the effect size, and the interval together.
Power, effect size, and study design
Power is the probability of rejecting the null when a specified effect is genuinely present. It rises with three levers: a larger true effect, a larger sample, and a more generous significance level. Because power is defined against a particular alternative, you must state the effect size you want to detect before you can compute it â which is exactly the discipline that prevents underpowered studies from being designed by accident.
Cohen's d standardises a mean difference by the pooled standard deviation so that benchmarks transfer across domains: zero point two is small, zero point five medium, zero point eight large. For a two-group comparison at the five percent level with eighty percent power, detecting a medium effect needs roughly sixty-four observations per group; detecting a small effect needs around eight times that. The standard approximation for the required sample size squares the sum of the two critical values and divides by the squared effect size, which makes the quadratic cost of precision explicit.
đĄPower runs in both directions
An observed effect with a non-significant p-value from an underpowered study is not evidence of no effect. Compute the power for the effect size you care about, or read the confidence interval and ask whether it is narrow enough to exclude meaningful values.
Running and reporting tests in Python
import numpy as np
from scipy import stats
def one_sample_test(sample, mu0=0.0, alpha=0.05):
x = np.asarray(sample, dtype=float)
t, p = stats.ttest_1samp(x, mu0)
n = x.size
se = x.std(ddof=1) / np.sqrt(n)
crit = stats.t.ppf(1 - alpha / 2, df=n - 1)
return {"t": t, "p": p, "ci": (x.mean() - crit * se, x.mean() + crit * se),
"reject": p < alpha}
def cohens_d(a, b):
na, nb = len(a), len(b)
pooled = np.sqrt(((na - 1) * np.var(a, ddof=1) +
(nb - 1) * np.var(b, ddof=1)) / (na + nb - 2))
return (np.mean(a) - np.mean(b)) / pooled
def required_n(d, alpha=0.05, power=0.80, two_sided=True):
z_alpha = stats.norm.ppf(1 - alpha / (2 if two_sided else 1))
z_beta = stats.norm.ppf(power)
return int(np.ceil(2 * ((z_alpha + z_beta) / d) ** 2))
rng = np.random.default_rng(3)
control = rng.normal(100, 15, size=30)
treated = rng.normal(107, 15, size=30)
print(one_sample_test(control, mu0=100))
print("Cohen's d:", round(cohens_d(control, treated), 3))
print("n per group for d=0.5:", required_n(0.5))
print("n per group for d=0.2:", required_n(0.2))
The sample-size calls make the design trade-off concrete: a medium effect needs sixty-four per group while a small one needs roughly eight hundred, before any allowance for attrition or multiple comparisons.
A simulation-based power curve complements the closed-form approximation and works for any test you can run.
import numpy as np
from scipy import stats
def empirical_power(effect, n=30, alpha=0.05, repeats=5000, seed=0):
rng = np.random.default_rng(seed)
rejected = 0
for _ in range(repeats):
a = rng.normal(0.0, 1.0, n)
b = rng.normal(effect, 1.0, n)
p = stats.ttest_ind(a, b).pvalue
rejected += p < alpha
return rejected / repeats
for effect in (0.0, 0.2, 0.5, 0.8):
print(f"effect d={effect}: power={empirical_power(effect):.3f}")
With no true effect the rejection rate sits at the nominal five percent, which is the definition of a well-calibrated test. As the effect grows the rate climbs toward one, and the curve it traces is the power curve you would quote in a study proposal.
Significance habits that corrupt results
Common Mistakes
Reading a p-value as the probability that the null hypothesis is true
Fix: It is the probability of data this extreme given the null; the null has no posterior probability in this framework.
Saying a non-significant result means there is no effect
Fix: Check power and the confidence interval; an underpowered study cannot distinguish absence from undetectability.
Choosing one-sided after seeing which way the data lean
Fix: Commit to the direction before collecting data, or report the two-sided p-value.
Running many tests and reporting the smallest p-value
Fix: Apply a correction such as Holm or control the false discovery rate, and pre-register the primary comparison.
Reporting significance without an effect size
Fix: Quote Cohen's d or the raw difference with its interval so readers can judge importance.
Equating statistical significance with practical importance
Fix: Ask what the effect costs or saves at realistic scale before acting on it.
Hypothesis testing essentials
Where to go next
- Null and Alternative Hypothesis shows common formulation patterns and sidedness choices.
- Type I and Type II Errors develops the error matrix with domain-specific examples.
- P-Values catalogues the standard misinterpretations and their fixes.
- Power of a Test covers a priori and sensitivity power analysis in detail.