534 Chapter 12:Nonparametric Hypothesis Tests
large or too small to be explained by chance. Specifically, if the observed number of runs
isr, then thep-value of the runs test is
p-value=2 min(PH 0 {R≥r},PH 0 {R≤r})
Program 12.5 uses Equation 12.5.1 to compute thep-value.
EXAMPLE 12.5a The following is the result of the last 30 games played by an athletic team,
withWsignifying a win andLa loss.
WWWLWWLWWLWLWWLWWWWLWLWWWLWLWL
Are these data consistent with pure randomness?
SOLUTION To test the hypothesis of randomness, note that the data, which consists of
20 W’s and 10L’s, contains 20 runs. To see whether this justifies rejection at, say, the
5 percent level of significance, we run Program 12.5 and observe the results in Figure 12.6.
Therefore, the hypothesis of randomness would be rejected at the 5 percent level of
significance. (The striking thing about these data is that the team always came back to
win after losing a game, which would be quite unlikely if all outcomes containing 20 wins
and 10 losses were equally likely.) ■
The above can also be used to test for randomness when the data values are not just
0’s and 1’s. To test whether the dataX 1 ,...,XNconstitute a random sample, let s-med
denote the sample median. Also letndenote the number of data values that are less than
or equal to s-med andmthe number that are greater. (Thus, ifnis even and all data values
The p-value for the Runs Test for Randomness
Enter the number of 1's:
Enter the number of 0's:
Enter the number of runs:
20
10
20
The p-value is 0.01845
Start
Quit
This program computes the p-value for the runs test of the hypothesis
that a data set of n ones and m zeroes is random.
FIGURE 12.6