STEP-BY-STEP TECHNOLOGY GUIDE: Generating a Random Sample

We illustrate using Example 12 (page 21).

TI-84

Set up the TI-84 Menus (For calculators without STATWIZARD, you may skip these steps.)

  • Step 1 Press 2nd then Catalog.
  • Step 2 Scroll down to STATWIZARD OFF. Highlight it and press ENTER (see Figure 5). Press ENTER again.
    image
    Figure 1.5: FIGURE 5

31

TI-83/84

Generate a random sample

  • Step 1 Enter a “seed,” which can be any nonzero number.
  • Step 2 Press STO ⇒.
  • Step 3 Press MATH, highlight PRB, select 1: rand, and press ENTER (see Figure 6, which uses 1776 for the seed). Your seed number is now in the calculator's memory.
  • Step 4 Press MATH, highlight PRB, and select 5: randInt(.
  • Step 5 Enter 1, N, two times n, where N = population size and n = sample size. We enter twice the sample size in case repeats occur. For Example 12, because n = 7, we enter randInt(1, 30, 14) and press ENTER (Figure 7).
  • Step 6 Store the random sample in list L1 as follows: press STO ⇒, then 2nd, then L1 (Figure 7). Then press Enter.
  • Step 7 View the random sample by pressing STAT, highlighting EDIT, and pressing ENTER (Figure 8). The random sample for Example 12 is therefore 28, 7, 25, 6, 4, 2, 20.
    image
    Figure 1.6: FIGURE 6
    image
    Figure 1.7: FIGURE 7
    image
    Figure 1.8: FIGURE 8

EXCEL

  • Step 1 Select cell A1. Click the Insert Function icon fx.
  • Step 2 For “Search for a function,” enter randbetween. Click Go, then OK.
  • Step 3 For Bottom, enter 1. For Top, enter population size N. For Example 12, N = 30. Click OK.
  • Step 4 Cell A1 now contains a random integer between 1 and N. Copy and paste cell A1 into twice as many cells as needed for the sample size n, just in case repeats occur. For Example 12, copy and paste into cells A2 to A14. The results are shown in Figure 9. Note that 17, 16, and 5 are repeated, so that our random sample is 3, 17, 16, 5, 25, 24, 28.
    image
    Figure 1.9: FIGURE 9 Excel random sample.

MINITAB

  • Step 1 Click on Calc > Random Data > Integer
  • Step 2 In the Number of rows of data to generate section, enter twice your desired sample size, just in case repeats occur. For example, if your desired sample size is 7, enter 14.
  • Step 3 In the Store in column(s) section, enter whichever column is convenient for you, such as C1.
  • Step 4 For Minimum value, enter 1. For Maximum value, enter your population size, N. Click OK.
  • Step 5 The random integers appear in column C1. Start from the top and go down the list, omitting any repeats, until you have your sample of size N. Our random sample (Figure 10) is therefore 23, 25, 24, 30, 15, 9, 13.
    image
    Figure 1.10: FIGURE 10 Minitab random sample.

Excel and Minitab base the seed on the current time, so that you need not set it yourself.

32

SPSS

  • Step 1 Select the top-right cell. Enter 0, which appears as .00. Click the Variable View tab, select the Name of the variable (currently VAR00001) and type Sample to rename the variable. Press ENTER.
  • Step 2 Select the Data View tab, and fill in rows 1 through 14 of Sample with the value 0.
  • Step 3 Click Transform > Compute Variable
  • Step 4 In Target Variable, enter Sample. In the Function Group menu, click Random Numbers. In Functions and Special Sample. Variables, double-click Rv.Uniform.
  • Step 5 In Numeric Expression, replace the first question mark with 0 and the second question mark with 30. Click OK, then OK again.
  • Step 6 Minimize the output window, and go back to your dataset. The results are shown in Figure 11. Round the values up to the nearest integer, skipping any repeats. Our random sample is then 22, 28, 18, 8, 2, 4, 7.
    image
    Figure 1.11: FIGURE 11 SPSS Random Sample.

JMP

  • Step 1 Click File, then New, then Data Table.
  • Step 2 Click Rows, then Add Rows …; in How many rows to add, enter twice your desired sample size. Click OK.
  • Step 3 Click Column 1, above the first row in the first column. Type Sample to rename the variable, and press ENTER.
  • Step 4 Right-click Sample and select Formula
  • Step 5 In the list under Functions (grouped), click Random, then Random Uniform. Double-click Random Uniform() inside the red box to edit the formula. Type *30, so that the entire formula is Random Uniform() * 30. Click OK.
  • Step 6 The results are in Figure 12. Round the values up to the nearest integer to obtain the random sample, omitting repeats. Our random sample is 17, 26, 30, 11, 14, 6, 25.
    image
    Figure 1.12: FIGURE 12 JMP random sample.

CRUNCHIT!

  • Step 1 Select Insert, then Random Numbers, then Uniform.
  • Step 2 For Minimum, enter 1. For Maximum, enter 30. For Samples, enter 14. Click Sample. The results are in Figure 13.
  • Step 3 Round the numbers up to the nearest integer, and skip repeated numbers. Our random sample is then 14, 30, 11, 12, 7, 15, and 10.
    image
    Figure 1.13: FIGURE 13 Crunchit! random sample.