CHAPTER 8 Producing Data: Sampling 8.1 8.2 8.3 First Steps Sampling Design Selected Exercise Solutions Introduction In this chapter, we use TI calculators to simulate the collection of random samples. We also provide a supplementary program that can be used to draw a random sample without repeats from a list of integers numbered from m to n. Good data collection practice involves randomly selecting individuals from the population, or randomly assigning treatments in a controlled experiment. The randomization can be done with a random digits table, a calculator, or a computer. When your text says start on line xx of Table B the sample drawn in that manner will not be random this is merely a mechanism to be able to write an answer for the back of the book. 54
Simulation First Steps 55 8.1 First Steps In this section, we demonstrate how to generate count data, or Bernoulli trials, for a specified proportion p. The data simulates observational Yes/No outcomes obtained from a random survey. To generate the data, we use the randbin command from the MATH PRB menu (option 7). Example Simulating a Survey. Suppose that 62% of students hold a part-time or fulltime job at a particular university. Simulate the results of a random survey of 200 students and determine the sample proportion of those who have a job. TI-83/84 Solution. To generate a random list of 1 and 0 responses ( Yes/No ), enter the command randbin(1,p,n) L1, where p is the specified proportion of yeses (these will be 1 s in our data), and n is the desired sample size. Here, use randbin(1,.62,200) L1. Then enter the command 1-Var Stats L1. Notice after the command is executed, the first few values are shown on the screen. To be able to see the whole list, use the Statistics Editor. In our sample, we actually had 64% successes. TI-89 Solution. In the Stats/List Editor application, move the cursor to highlight the list name that will hold our random data. Press for the Calc menu, arrow down to option 4:Probability, and press the right arrow to expand the options. Press to select randbin. Complete the command by entering the parameters 1,.62,200 then close the parentheses and press Í to execute. You will see the first few entries in the generated list, and can page down to view the entire list, if desired. We show the results of performing 1-Var Stats on this generated data to show that results are random here, we had 63.5% 1 s. Using the calculator to generate random samples is not truly random. These are really pseudorandom numbers. The calculator uses a value called a seed to control the sequence. This seed is changed each time a random number is generated, so results should appear random each time.
56 Chapter 8 Producing Data: Sampling Example Changing the Seed. We really want random numbers each time. However, just as your text will instruct you to start in line xx when using the table of random digits, your instructor may ask that you use a particular seed so that each student will get the same random numbers. Good seed numbers are large, odd, and preferably prime numbers. The method of setting the seed varies with calculator type. Well follow the seed setting with a randint command (also found on the MATH PRB menu) to simulate throwing a die. TI-83/84 Solution. Type the desired seed number on the home screen. Press. Then, from the MATH PRB menu, select option 1:rand. Press Í and the calculator will echo the seed number back. Immediately follow this with the randint(1,6) to randomly generate numbers from 1 to 6 (inclusive). To keep generating values, keep pressing Í. If you use my seed as at right, you will get the same random numbers. TI-89 Solution. The seed can be set from the home screen using option 6:randseed from the Math Probability menu. Type in the desired seed and press Í to see the Done message. This can also be done in the Stats/List Editor application using option A:randseed from the Calc Probability menu. Example Simulating IQ Scores. Generate 150 observations from a N(100,15) distribution. This distribution will mimic scores for individuals on the Wechsler Adult Intelligence Scale. Compute the sample statistics to compare x with 100 and to compare s with 15. Solution. From the MATH PRB menu, select 6:randNorm(. Complete the command by entering the parameters 100,15,150) L1 and then compute the sample statistics. If you are using a TI-89, the procedure is essentially the same as used above select option 6:.randnorm from the Calc Probability menu. Notice that on the home screen, many more decimal places are shown than in the list editor. One point to make here, is that normal random variables are truly continuous (many decimal places are possible) while the IQ scores are really discrete (or at least rounded).
Sampling Design 57 My sample mean (101.5) and standard deviation (15.24) are close to the parameter values, but not exactly the same. 8.2 Sampling Design The RANDOM program listed below can be used to choose a simple random sample from a designated population numbered from m to n. This program chooses the sample all at once without repeated choices. It also can be used to permute an entire set of n subjects so that the group can be assigned randomly to blocks. The program displays the random choices and also stores the values into list L1. The RANDOM Program PROGRAM:RANDOM :Disp "LOWER BOUND" :Input M :Disp "UPPER BOUND" :Input N :Disp " HOW MANY?" :Input R :ClrList L4 :seq(j,j,m,n) L1 :For(I,1,R) :ClrList L5 :randint(1,n-m+2-i) A :L1(A) L4(I) :1 K :While K<A :L1(K) L5(K) :1+K K :End :A K :While K N-M+1-I :L1(K+1) L5(K) :1+K K :End :L5 L1 :End :L4 L1 :ClrList L5,L4 :ClrHome :Output(1,2,L1) :Stop Example 8.4 Sampling spring break resorts. A campus newspaper plans a major article on spring break destinations. The authors intend to call 4 randomly chosen resorts at each destination to ask about their attitudes toward groups of students as guests. Here are the resorts listed in one city. 01 Aloha Kai 08 Captiva 15 Palm Tree 22 Sea Shell 02 Anchor Down 09 Casa del Mar 16 Radisson 23 Silver Beach 03 Banana Bay 10 Coconuts 17 Ramada 24 Sunset Beach 04 Banyan Tree 11 Diplomat 18 Sandpiper 25 Tradewinds 05 Beach Castle 12 Holiday Inn 19 Sea Castle 26 Tropical Breeze 06 Best Western 13 Lime Tree 20 Sea Club 27 Tropical Shores 07 Cabana 14 Outrigger 21 Sea Grape 28 Veranda
58 Chapter 8 Producing Data: Sampling Use random numbers to select the four resorts. TI-83/84 Solution: We can either use the function randint from the PRB menu or the program RANDOM. We ll illustrate both methods. First, using randint enter the low end of our numbered group (1 = Aloha Kai) and the high end of our numbered group (28 = Veranda). Press Í until you have four non-repeated values. Here, we selected resorts numbered 27, 26, 5, and 15 which correspond to Tropical Shores, Tropical Breeze, Beach Castle, and Palm Tree. If we use program RANDOM, we specify the low end, the high end, and how many numbers are desired, pressing Í after each. The program selected resorts numbered 12, 14, 26, and 4 which correspond to Holiday Inn, Outrigger, Tropical Breeze, and Banyan Tree. TI-89 Solution: To generate several random numbers, place the cursor highlighting the name of an empty list. Press (Calc), then y (Probability) and z (randint). Enter the low number on the list, the high number, and the number of random integers to generate. Notice that I have asked for 6 here, in case there are duplicates. The TI-89 selected resorts numbered 17, 19, 10, and 15 which correspond to Ramada, Sea Castle, Coconuts, and Palm Tree.
Selected Exercise Solutions 59 8.3 Selected Exercise Solutions 8.7 The managers are numbered 1 through 28. We can use the randint function from the, PRB menu (ignoring any duplicates) to select six to be interviewed as shown below. We can also use program RANDOM to do the same thing. The randint function selected Agarwal, Peters, Puri, Brown, Gomez, and Baxter. Program RANDOM selected Chavez, Peters, Agarwal, Lumumba, Santiago, and Rodriguez. Since the selection is supposed to be random, we don t expect the same individuals to be chosen. 8.29 The plots should be labeled from 1 to 1410, or if using a random digits table, from 0001 to 1410. How one actually labels the map might be arbitrary (upper left to lower right, etc). To select the first five plots in a sample of 141, we ll use randint as shown at right. Continue your practice with these exercises: 8.11 Sampling metro Chicago. 8.27 Do you trust the internet? 8.39 Sampling at a party.