Mathematics · Simulator 052
Run the same experiment thousands of times. When there is no real effect, see how often you still get “significant” results (false positives). When there is a real effect, see how often you detect it (power), and how both depend on sample size and the significance threshold.
CollegeCollege statistics
Each simulated experiment compares a treatment group with a control group (n per group, values with standard deviation 1). A two-sample z-test gives a p-value: the probability of a difference at least this large if there were no real effect (the null hypothesis).
The “peek and stop” option checks after every 10 participants and stops as soon as p < α. That inflates false positives well above α, a common real-world error.
Normal data with known variance (z-test) for clarity. Real studies often use t-tests and face many other issues.
How many participants per group do you need for 80% power to detect d = 0.5 at α = 0.05 (two-sided)?
Need d√(n/2) ≈ 1.96 + 0.84 = 2.80, so √(n/2) = 5.6 and n ≈ 63 per group. Set d = 0.5 and n = 63 and check that the measured power is near 80%.
One experiment: two groups of 50, outcome measured in standard-deviation units. The treated group's mean is 0.5 higher.
Test statistic: the standard error of the difference is √(2/50) = 0.2, so z = 0.5 / 0.2 = 2.5.
p-value: 2 × (1 − Φ(2.5)) ≈ 2 × 0.0062 ≈ 0.012. That is below α = 0.05, so the result is called significant.
Power: if the true effect is d = 0.5, the chance of a significant result with 50 per group is Φ(0.5 × √25 − 1.96) = Φ(0.54) ≈ 71%. About 3 in 10 such studies would miss a real effect.
Many tests: run 20 independent tests where nothing is going on, and the chance of at least one false positive is 1 − 0.95²⁰ ≈ 64%. Set d = 0.5 and n = 50 and compare the measured share with 71%.
The probability of getting a result at least as extreme as the one observed if there were really no effect. It is not the probability that the null hypothesis is true.
A Type I error is a false positive: declaring an effect that is not there, which happens with probability α. A Type II error is a false negative: missing a real effect, which happens with probability 1 − power.
Every look is another chance for random noise to cross the threshold. Stopping at the first significant look turns a 5% test into a much higher one unless the threshold is adjusted for the number of looks.