Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Sampling supplying own seed.

Status
Not open for further replies.

nancier

MIS
Dec 27, 2004
50
US
Hi, I am doing a basic random sample, querying for 100 random items from a 20,000 item table. I've tried numerous examples using Rnd and Randomize that work fine. In these examples though, the seed numbers are chosen by the system clock. Nowhere have I found a way to supply my own seed number, ie. 7777777 so that someone on another computer using the same table would be able to supply the same seed number and come up with the same results. Does anyone know if this is possible and what code would be used.

Thanks
 
The full specification for Randomize is
Code:
Randomize [number]
If you don't supply "Number" then the system clock is used as the seed. If you do supply it as in
Code:
Randomize 7777777
then the same random number sequence will be generated each time it runs.
 
Didn't get that quite right. From Help
Note To repeat sequences of random numbers, call Rnd with a negative argument immediately before using Randomize with a numeric argument. Using Randomize with the same value for number does not repeat the previous sequence.
 
Hi, thanks for the reply. Does that say to you that someone on a different computer would not be able to use the same seed 777777 and get the same results?

Thanks
 
Nancier

You are correct: it will not return the same results on different computers, or the same computer if run multiple times.

Best advice I can give you is to write your own "random number" generation function, which does arbtirary calculations to an input number, and returns a result.
You have to be careful though that what you calculate on won't give output weighted in any particular direction.

John
 
Ok, appreciate the answer. I don't have the knowledge to create my own "random number" generation function". If you or anyone else is aware of any function that's already been written where a seed can be inputted, please let me know.

Thanks very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top