is RND really random?

J

John

In many random functions you have to seed it to get a really random
first number.You do this with the date or something like that.

How does rnd work? Does it always produce the same sequence of random
numbers or does it somehow seed itself to start randomly?

John
 
J

JLGWhiz

In the VBA help file they have the following advisory.

For any given initial seed, the same number sequence is generated because
each successive call to the Rnd function uses the previous number as a seed
for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to
initialize the random-number generator with a seed based on the system timer.

It also depends on how large your universe is that you are trying to
randomize.
 
J

John

thanks... I should have checked that.
John
In the VBA help file they have the following advisory.

For any given initial seed, the same number sequence is generated because
each successive call to the Rnd function uses the previous number as a seed
for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to
initialize the random-number generator with a seed based on the system timer.

It also depends on how large your universe is that you are trying to
randomize.
 
J

Jim Cone

Use the "randomize" statement immediately before calling the
Rnd function to seed the function.
Do not use randomize inside a loop or you can get non-random patterns.

It does not make all statisticians happy with its performance.
The WorksheetFunction.Rand function is preferred by some.
Do a search (in the programming group) for "Bias in rnd for excel 07"
for some discussion on the issue.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins - free Special Randoms workbook - no registration required)



"John" <[email protected]>
wrote in message
In many random functions you have to seed it to get a really random
first number.You do this with the date or something like that.
How does rnd work? Does it always produce the same sequence of random
numbers or does it somehow seed itself to start randomly?
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top