Re: Random number generators in IDL [message #8054] |
Wed, 05 February 1997 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Michael Lefsky <mal3p@faraday.clas.Virginia.EDU> writes:
> Is there any known problem with the number generators in idl?
> I am printing out sequences of 300 random numbers generated with
> RANDOMU and getting exactely the same sequence. ANy help would
> be appreciated.
Sounds like you are always starting with the same seed. The
IDL random number generators, like most (all?) random number
generators on computers, produces a pseudo-random sequence
of numbers. If you always start with the same seed, you will
always get the same pseudo-random sequence.
Widget programs sometimes run into random number problems
if the event handler depends on a random number sequence.
If you go into the event handler quickly, over and over, you can
appear to get the same number out of the generator. The trick
here is to store the seed in a common block (yuck!). Or, if you
hate common blocks as much as I do, store the seed in the
info structure. (This way you can have many independent
random number processes going all at once!)
Cheers!
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
|
|
|