WOLFRAM|DEMONSTRATIONS PROJECT

p-Values Are Random Variables

​
sample size, n
30
n
δ
0
random seed
1987
number of simulations
3
10
4
10
graph
histogram
Q-Q Plot
We consider
p
-values for
3
10
or
4
10
simulations using a random sample of size
n
from a normal distribution with mean
δ
n
and unit variance to compute the two-sided
p
-values for the test of the null hypothesis,
H
0
:μ=0
versus
H
a
:μ=δ
n
using the
t
-distribution method as implemented in the Mathematica function MeanTest. When
δ=0
, the
p
-values are uniformly distributed on
(0,1)
. With
3
10
simulations, the result is obtained very quickly but there is more random variability in the histogram. Increasing to
4
10
simulations takes less than three seconds on most modern computers and provides a more accurate result.
Mouseover the first rectangle to see the estimate of the probability of the power of a 5% test; the area of this rectangle represents observed probability of
p
-values in the interval
(0,0.05)
.
The slider
n
δ
changes the alternate hypothesis. When
δ>0
, the
p
-values are no longer uniform on
(0,1)
. The area under the first rectangle gives an estimate of the probability that the
p
-value is less than 0.05. This is the estimated power of a two-sided test at the 5% level for
H
a
:μ=δ
n
.
The distribution of the
p
-values may also be visualized using a Q-Q plot in which the quantiles of the
p
-values are plots against the corresponding quantiles from a uniform
(0,1)
distribution.