1Population & hypotheses
H₀: μ = μ₀. Move δ away from 0 to make H₀ false. Drag on the chart to draw your own population.
2Test statistic z
3Distribution of p-values
Each experiment gives one p-value. Bars in colour are p ≤ α: H₀ rejected.
Hypothesis Testing Simulator
H₀: μ = μ₀. Move δ away from 0 to make H₀ false. Drag on the chart to draw your own population.
Each experiment gives one p-value. Bars in colour are p ≤ α: H₀ rejected.
What you see. Each experiment draws a sample of N values from the population in panel 1 and tests H₀: μ = μ₀ with a z test (σ known): z = (x̄ − μ₀)/(σ/√N). Panel 2 collects the z values, panel 3 the p-values, and panel 4 counts how often H₀ was rejected. The slider δ sets how far the true mean μ is from μ₀, in units of σ; at δ = 0 H₀ is true.
The p-value. If H₀ is true, z follows the standard normal curve (dashed in panel 2). The p-value is the area under that curve at least as far out as the z you got — shaded for the latest experiment. A small p says "if H₀ were true, a result this extreme would be rare". It is not the chance that H₀ is true.
Things to try.
Details. The shapes on 0–32 are treated as continuous: each bar is a bin of width 1 and a draw lands anywhere inside it, so σ is slightly larger than the bar heights alone suggest. The coin, the die and Bernoulli stay discrete. The theory curves assume x̄ is normal, so z ~ N(λ, 1) with λ = δ√N. Panel 4 keeps the results for every δ you have tried with the current population and N.
Colours. Red ochre is the population and grey the latest sample. In panels 2–4 the colour marks rejections — dark blue for z, dark green for p, purple for the rejection rate — and grey bars are experiments where H₀ was kept. Dashed lines are theory.