p-values in this visualization
A hypothesis test asks whether data would be surprising under a default claim, the null hypothesis . Here says that a machine fills bags with g on average; bag weights are independent and normal with g, and a study weighs bags and takes their mean . The p-value is the probability, computed as if were true, of a mean at least as extreme as the observed one, in the direction named by the alternative hypothesis . A test at level raises an alarm when .
What exactly is p the probability of? Under the mean is normal with mean 500 and standard error , so the observed mean sits at . For the p-value is the area to the left of , ; for it is the area to the right; for it is both tails, . The reruns show the same thing by counting: on a machine that truly fills 500 g, the share of studies whose mean is at least this extreme settles near p. The direction has to be chosen before the data are seen. Picking the smaller of the two one-sided p-values afterwards raises an alarm 10% of the time when is true, twice the stated rate. With the direction fixed in advance, p is uniformly distributed between 0 and 1 under , so the test raises a false alarm exactly a fraction of the time.
Why is p not the probability that is true? It is computed entirely inside the world of : it is , not . Turning it around needs two quantities that p never uses: how common short machines are to begin with, and the power, the chance that the test raises an alarm on a short machine. With 25 bags and a 3 g shortfall the power is about . In the odds form of Bayes' theorem, an alarm multiplies the odds of short against good by power ÷ , about 8.85 here, taking prior odds of 1 : 4 to about 2.2 : 1. After the same alarm, the share of good machines among the alarms is about 2.7% when 80% of machines are short and about 68% when 5% are. These shares use only the fact that an alarm was raised; the value of itself says more.
Why can a tiny difference be significant? For a fixed observed shortfall, grows with , so the lower-tail p gets smaller as more bags are weighed: four times as many bags doubles . In the lower-tail test, half a gram below 500 is significant at from 1083 bags on. A small p says that the data would be unusual if were exactly 500; it does not say that the difference matters. The converse fails too: a real shortfall often raises no alarm, so does not show that the machine is fine. Report the size of the difference with a confidence interval: the two-sided test at rejects exactly when the 95% interval () leaves out 500.
Things to notice
- The bags in the upper layer are example data placed so that their mean is exactly ; the test uses only , and .
- The lower axis always spans six standard errors either side of 500, so the curve keeps its shape; the frame under the upper axis marks that window, and it narrows as grows.
Controls
- Drag on the lower layer to place . Moving or the direction lever recounts the same reruns; a new starts both modes afresh.