XL: Using RAND() to Generate Randomly Distributed Integers
ID: Q96746
|
The information in this article applies to:
-
Microsoft Excel for Windows, versions 2.x, 3.x, 4.x, 5.0, 5.0c
-
Microsoft Excel for Windows NT, version 5.0
-
Microsoft Excel for Windows 95, version 7.0
-
Microsoft Excel 97 for Windows
-
Microsoft Excel for the Macintosh, versions 2.x, 3.0, 4.0, 5.0
-
Microsoft Excel 98 Macintosh Edition
SUMMARY
Microsoft Excel does not include a built-in method for generating sets
of randomly sorted, uniformly distributed integers. The information
in this article describes how you can use the RAND function (which is
integral to Microsoft Excel) to create a set of this kind.
MORE INFORMATION
Below is an example of a set of randomly sorted, uniformly distributed
integers from 1 to 10:
10 5 7 4 8 1 6 2 3 9
The set is said to be uniformly distributed because every value in the
range occurs exactly once.
To generate such a set of randomly sorted, uniformly distributed
integers, follow these steps:
- In a new worksheet, enter the following formulas:
A1: =RAND() B1: 1
A2: =RAND() B2: 2
A3: =RAND() B3: 3
A4: =RAND() B4: 4
A5: =RAND() B5: 5
A6: =RAND() B6: 6
A7: =RAND() B7: 7
A8: =RAND() B8: 8
A9: =RAND() B9: 9
A10: =RAND() B10: 10
- Select the range A1:B10.
- On the Data menu, click Sort.
- In the 1st Key box, enter A1 and click OK to sort the range.
After the sort is complete, cells B1:B10 contain a set of randomly sorted,
uniformly distributed integers that range from 1 to 10. Each time the
range is sorted, the integers in B1:B10 are resorted randomly, which
results in a new set.
REFERENCES
"Microsoft Excel Function Reference," version 4.0, page 344
"Microsoft Excel Function Reference," version 3.0, page 191
"Microsoft Excel Functions and Macros," version 2.1 for Windows, page 396
Additional query words:
2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 4.00 4.0a 4.00a 5.0 5.00a 5.00c 8.00 97 98 XL98 XL97 XL7 XL5 XL4 XL3 randbetween analysis toolpak toolpack tool pak pack pick hat numbers out unique random numbers
Keywords : xlformula
Version : WINDOWS:2.0,3.0,4.0,5.0,5.0c,7.0,97; MACINTOSH:2.0,3.0,4.0,5.0,98
Platform : MACINTOSH OS/2 WINDOWS
Issue type : kbinfo
|