Title: Runs Test for Randomness
1Lesson 15 - 2
2Objectives
- Perform a runs test for randomness
- Runs tests are used to test whether it is
reasonable to conclude data occur randomly, not
whether the data are collected randomly.
3Vocabulary
- Runs test for randomness used to test claims
that data have been obtained or occur randomly - Run sequence of similar events, items, or
symbols that is followed by an event, item, or
symbol that is mutually exclusive from the first
event, item, or symbol - Length number of events, items, or symbols in a
run
4Runs Test for Randomness
- Assume that we have a set of data, and we wish to
know whether it is random, or not - Some examples
- A researcher takes a systematic sample, choosing
every 10th person who passes by and wants to
check whether the gender of these people is
random - A professor makes up a true/false test and
wants to check that the sequence of answers is
random
5Runs, Hits and Errors
- A run is a sequence of similar events
- In flipping coins, the number of heads in a row
- In a series of patients, the number of female
patients in a row - In a series of experiments, the number of
measured value was more than 17.1 in a row - It is unlikely that the number of runs is too
small or too large - This forms the basis of the runs test
6Runs Test (small case)
- Small-Sample Case If n1 20 and n2 20, the
test statistic in the runs test for randomness is
r, the number of runs. - Critical Values for a Runs Test for Randomness
Use Table IX (critical value at a 0.05)
7Runs Test (large case)
Large-Sample Case If n1 gt 20 or n2 gt 20 the test
statistic in the runs test for randomness is
2n1n2 µr -------- 1
n
r - µr z ------- sr
where
Let n represent the sample size of which there
are two mutually exclusive types. Let n1
represent the number of observations of the first
type. Let n2 represent the number of observations
of the second type. Let r represent the number of
runs.
Critical Values for a Runs Test for
Randomness Use Table IV, the standard normal
table.
8Hypothesis Tests for Randomness Use Runs Test
Step 0 Requirements 1) sample is a sequence of
observations recorded in order of their
occurrence 2) observations have two mutually
exclusive categories. Step 1 Hypotheses
H0 The sequence of data is random. H1 The
sequence of data is not random. Step 2 Level of
Significance (level of significance determines
the critical value) Large-sample case
Determine a level of significance, based on the
seriousness of making a Type I error.
Small-sample case we must use the level of
significance, a 0.05. Step 3 Compute Test
Statistic Step 4 Critical Value Comparison
Reject H0 if Step 5 Conclusion Reject or
Fail to Reject
r - µr z0 ------- sr
Small-Sample r Large Sample
Small-Sample Case r outside Critical
interval Large-Sample Case z0 lt -za/2 or z0 gt
za/2
9Example 1
The following sequence was observed when flipping
a coin H, T, T, H, H, T, H, H, H, T, H, T, T,
T, H, H The coin was flipped 16 times with 9
heads and 7 tails. There were 9 runs observed.
Values n 16 n1 9 n2 7 r 9
Critical values from table IX (9,7) 4, 14
Since 4 lt r 9 lt 14, then we Fail to reject and
conclude that we dont have enough evidence to
say that it is not random.
10Example 2
The following sequence was observed when flipping
a coin H, T, T, H, H, T, H, H, H, T, H, T, T,
T, H, H, H, TT, T, T, H, H, T, T, T, H, T, T, H,
H, T, T, H, T, T, T, T The coin was flipped 38
times with 16 heads and 22 tails. There were 18
runs observed.
Values n 38 n1 16 n2 22 r 18
2n1n2 µr -------- 1
19.5263 n
r - µr z --------- ?r
z -0.515
Since z (-0.515) gt -Za/2 (-2.32) we fail to
reject and conclude that we dont have enough
evidence to say its not random.
11Example 3, Using Confidence Intervals
- Trey flipped a coin 100 times and got 54 heads
and 46 tails, so - n 100
- n1 54
- n2 46
r - µr z --------- ?r
We transform this into a confidence interval,
PE /- MOE.
12Using Confidence Intervals
- The z-value for a 0.05 level of significance is
1.96 - LB 50.68 1.96 4.94 41.0
- to
- UB 50.68 1.96 4.94 60.4
- We reject the null hypothesis if there are 41 or
fewer runs, or if there are 61 or more - We do not reject the null hypothesis if there are
42 to 60 runs
13Summary and Homework
- Summary
- The runs test is a nonparametric test for the
independence of a sequence of observations - The runs test counts the number of runs of
consecutive similar observations - The critical values for small samples are given
in tables - The critical values for large samples can be
approximated by a calculation with the normal
distribution - Homework
- problems 1, 2, 5, 6, 7, 8, 15 from the CD