12.5The Runs Test for Randomness 535
are distinct, thenn=m=N/2.) DefineI 1 ,...,INby
Ij=
{
1ifXj≤s-med
0 otherwise
Now, if the original data constituted a random sample, then the number of runs in
I 1 ,...,INwould have a probability mass function given by Equation 12.5.1. Thus, it
follows that we can use the preceding runs test on the data valuesI 1 ,...,INto test that
the original data are random.
EXAMPLE 12.5b The lifetime of 19 successively produced storage batteries is as follows:
145 152 148 155 176 134 184 132 145 162 165
185 174 198 179 194 201 169 182
The sample median is the 10th smallest value — namely, 169. The data indicating whether
the successive values are less than or equal to or greater than 169 are as follows:
1111010111100000010
Hence, the number of runs is 8. To determine if this value is statistically significant, we
run Program 12.5 (withn=10,m=9) to obtain the result:
p-value=.357
Thus the hypothesis of randomness is accepted. ■
It can be shown that, whennandmare both large andH 0 is true, Rwill have
approximately a normal distribution with mean and standard deviation given by
μ=
2 nm
n+m
+1 and σ=
√
2 nm(2nm−n−m)
(n+m)^2 (n+m−1)
(12.5.2)
Therefore, whennandmare both large
PH 0 {R≤r}=PH 0
{
R−μ
σ
≤
r−μ
σ
}
≈P
{
Z≤
r−μ
σ
}
, Z∼N(0, 1)
=
(
r−μ
σ
)