Rand function
Alex,
I've been one (of many?) to have complained about Excel's rng's since Excel
2.0. To expand on/add to what Mike and Jerry pointed out, try this to see
just how lousy the ATP rng is:
Use ATH (Tools- Data Analysis...) to generate 10 000 uniform random variates
between 0 and 1 into a new ply. When it is done, the cells A1-A10000 will be
selected. Rename it (Insert-Name-Define) to ATPran, say.
1) Select B1-B10000, and array-enter (ctrl-shift-enter)
=FREQUENCY(ATPran,ATPran).
2) Now select A1-B10000, copy, and Paste Special Values to C1. Sort
C1-D10000 on Column D, descending.
You will then see which numbers were repeated, and how many times.
To take it a step further, you can repeat the process on your output. Select
D1 to the last cell in D that contains 1 (all the rest contain 0). Copy it,
and paste it to F1; name it ATPran2. Select from G1 to Gx, where x is the
last row in F with data, and array-enter =FREQUENCY(ATPran2,ATPran2) into
the cells.
Copy and Paste-special the values in F and G into H1, and sort descending on
column I. When I just did this, I got
1 7370
2 1108
3 122
4 12
(ignore the 0's)
In other words, 12 numbers in that run were repeated 4 times, 122 were
repeated 3 times, 1108 were repeated 2 times. Only 73.7% of the numbers were
unique. I've done this and at times had numbers repeated 6 times!!! Also,
ATP can generate both 0 and 1, which is odd, and a hassle to deal with in
many instances.
Moral: IMO, don't use the ATP random number generator for anything,
whatsoever. Microsoft has been alerted to this for *many* years,and has yet
to address it.
HTH
Dave Braden
"Alexander Fischer" wrote in message
ups.com...
Hello all,
thanks for the comments so far.
Oddly enough, the worksheet RAND function, ATP routines (including
RANDBETWEEN), and the VBA Rnd function all use different algorithms.
None
were very random before Excel 2003. Only the worksheet RAND function was
improved in 2003.
That's really interesting. Any way to access the worksheet RAND
function from within Excel, by some construction like Call
ExcelWorksheetFunction.RAND() or something similar?
RANDBETWEEN may be more convenient, but should not be used
where serious randomness is required.
I couldn't care less about convenience :-) - I just want a truly random
double between 0 and 1 :-)
Al
|