Lesson 15 2 Runs Test for Randomness Objectives
Lesson 15 - 2 Runs Test for Randomness
Objectives • 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.
Vocabulary • 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
Runs 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 10 th 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
Runs, 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
Runs Test (small case) • Small-Sample Case: If n 1 ≤ 20 and n 2 ≤ 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 α = 0. 05)
Runs Test (large case) Large-Sample Case: If n 1 > 20 or n 2 > 20 the test statistic in the runs test for randomness is r - μr z = ------σr where 2 n 1 n 2 μr = ---- + 1 n σr = 2 n 1 n 2 (2 n 1 n 2 – n) -----------n²(n – 1) Let n represent the sample size of which there are two mutually exclusive types. Let n 1 represent the number of observations of the first type. Let n 2 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.
Hypothesis 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: H 0: The sequence of data is random. H 1: 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, α = 0. 05. Step 3 Compute Test Statistic: Small-Sample: r Step 4 Critical Value Comparison: Reject H 0 if Small-Sample Case: r outside Critical interval Large-Sample Case: z 0 < -zα/2 or z 0 > zα/2 Step 5 Conclusion: Reject or Fail to Reject r - μr Large Sample: z 0 = ------σr
Example 1 The following sequence was observed when flipping a coin: H, T, T, H, H, 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 n 1 = 9 n 2 = 7 r=9 Critical values from table IX (9, 7) = 4, 14 Since 4 < r = 9 < 14, then we Fail to reject and conclude that we don’t have enough evidence to say that it is not random.
Example 2 The following sequence was observed when flipping a coin: H, T, T, H, H, H, T, T, T, H, H, H, T T, T, T, H, 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 n 1 = 16 n 2 = 22 r = 18 r - μr z = ---- r 2 n 1 n 2 μr = ---- + 1 = 19. 5263 n z = -0. 515 σr = 2 n 1 n 2 (2 n 1 n 2 – n) -----------n²(n – 1) = 9. 9624 Since z (-0. 515) > -Zα/2 (-2. 32) we fail to reject and conclude that we don’t have enough evidence to say its not random.
Example 3, Using Confidence Intervals Trey flipped a coin 100 times and got 54 heads and 46 tails, so – n = 100 – n 1 = 54 – n 2 = 46 r - μr z = ---- r We transform this into a confidence interval, PE +/- MOE.
Using Confidence Intervals ● The z-value for α = 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
Summary 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
- Slides: 13