Page 368 - Excel for Scientists and Engineers: Numerical Methods
P. 368
CHAPTER 15 RANDOM NUMBERS & MONTE CARL0 METHOD 345
Selecting Items Randomly from a List
You can use RAND to rearrange the values in a table so as to put them in
random order, or to select a random sample from the table. There are two ways
you can do this: either manually, using the Sort command, or by means of a
formula. The former generates a randomized list that is %xed"; that is, once
randomized, the values in the list do not change. The latter method generates a
list that will change each time the spreadsheet is recalculated. Clearly, there are
advantages and disadvantages of either method.
To randomize manually, use =RAND() to generate a column of random
numbers adjacent to (and most convenient, to the left of) the column of values to
be randomized as shown in Figure 15-2.
Figure 15-2. A list of names before randomizing. Only part of the list is shown.
(folder 'Chapter 15 Examples', workbook 'Randomize', worksheet 'By Hand')
Then select the two columns and use the Sort command to Sort By the
values in the column of random numbers. If the random number column is the
leftmost column, you can use the Sort Ascending toolbutton fi. The
randomized list is shown in Figure 15-3. To choose a random sample of N
elements from the table, simply select, for example, the first N elements from the
list.