comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » random number trap
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
random number trap [message #4986] Tue, 29 August 1995 00:00 Go to previous message
peter is currently offline  peter
Messages: 80
Registered: February 1994
Member
A warning about the random number generator in IDL/PV-Wave (not a bug,
per se, but something to watch out for).

As the documentation states, if the seed value given to randomu is
undefined, it is derived from the system time. The time only changes
once per second, however. So if you repeatedly call a procedure that
calls randomu, the return will be the same if the calls occur within a
second of each other, but will be different if they are in different
seconds.

This can lead to random numbers being a *lot* more structured than you
expect. I had naively expected that the seed value would change each
microsecond, so this behavior came as a bit of a surprise.

The solution is to place the seed variable in a common block so that it
is preserved from call to call, and then each returned sequence will
truly be random.

Peter

--------------------------------
Peter Webb, HP Labs Medical Dept
E-Mail: peter_webb@hpl.hp.com
Phone: (415) 813-3756
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: determining postition on image?
Next Topic: Display into non-IDL apps/widgets?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:00:30 PDT 2025

Total time taken to generate the page: 0.00729 seconds