MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

The p-value, and how to fool yourself with it

Two thousand experiments ask whether a mean is zero; the share that rejects at α = 0.05 is counted. With no effect it is 5 % - the type I rate - and the p-values are uniform. With an effect it is the power, which rises with the effect and with n: half a σ is found 32 % of the time with ten observations and 82 % with thirty-four. Look at the data every five observations and stop when p dips below 0.05, and the false positive rate is a quarter. Everything is counted; Student's curve comes from the code.

The p-value, and how to fool yourself with it — Actual application image
Actual application image

What happens

A p-value answers a strange question: if there were no effect at all, how often would data this surprising turn up? This module runs the experiment two thousand times. With no effect, five per cent of runs cross the line - by construction, the p-value is uniform. With a real effect the fraction that crosses is the power, and it depends on the effect and on n: a small effect at n = 20 is caught one time in seven. Peek at the data as it comes and stop when p dips below 0.05, and the false-positive rate climbs past a quarter. Set δ and n, read the power, then try optional stopping.

Equations used in the module
Equations
t = m/(s/√n), Student with n − 1 degrees of freedom
under H₀ the p-value is uniform: P(p < α) = α
power ≈ Φ(δ√n − z_{1−α/2}) + Φ(−δ√n − z_{1−α/2})
optional stopping (look every 5, stop at p < 0.05): 27 % false positives

Related experiments

Back to catalogue
Three answers people refuse — Actual application image

Math

Three answers people refuse

Monty Hall: switching wins 2/3 - and only 1/2 if the host did not know where the prize was, though he opened the same door. The two children: 'at least one is a boy' makes two boys 1/3, 'the older is a boy' 1/2, 'a boy born on a Tuesday' 13/27. Bertrand's chord: a random chord is longer than the triangle's side with probability 1/3, 1/2 or 1/4, depending on what 'random' means. Every answer is an exact fraction and a count over twenty thousand seeded trials, and the picture shows the procedure that produced it.

Every distribution from the uniform — Actual application image

Math

Every distribution from the uniform

There are only a few ways to make a random number with a given distribution, and all of them start from a uniform. Push it through the inverse of the CDF (exponential, Cauchy, triangular). Take two and turn them into a pair of normals (Box-Muller). Throw darts at a box around the density and keep the ones under the curve (rejection - and the share kept is π/4 for the semicircle). Count exponential waits in a unit of time (Poisson) or heads in ten coins (binomial). Follow one numbered token through the machine, then hold the whole sample against its exact curve.

L-systems — Actual application image

Math

L-systems

A grammar of a few rules, grown into a plant: rewrite, walk, rewrite deeper.