Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default is RND really random?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default is RND really random?

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.



"John" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default is RND really random?

thanks... I should have checked that.
John

JLGWhiz wrote:
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.



"John" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default is RND really random?

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"
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random phantom breakpoints and random bogus compile errors Greg Lovern Excel Programming 5 June 2nd 10 03:52 PM
Sorting random Data created from a random formula Six Sigma Blackbelt Excel Discussion (Misc queries) 1 September 11th 08 11:03 PM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


All times are GMT +1. The time now is 12:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"