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

Home » Public Forums » archive » Re: Bizarre (?) behavior of randomu
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Bizarre (?) behavior of randomu [message #57846 is a reply to message #57831] Wed, 02 January 2008 14:24 Go to previous message
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
The trick is to preserve the 'seed' from one run to the next.
If you put the seed in a common block, for example, then it won't keep
getting reset every time you run the program.

So the first two lines of your program would become

pro rannummers
common rblock, seed ;--- common blocks need to be named.

I'm not an expert in (pseudo) random number generation, but I believe
that the whole point of the 'seed' argument is for when people need to
re-generate the exact same sequence of random numbers. You can see by
a simple test that if you give randomu() the same seed value, you get
the same sequence of numbers--every time.

Consequently, every time you restart IDL and run this program, you'll
get the same sequence of random numbers. That's the expected behavior.
Since you want different results every time, you have to set the seed
to a different value each time. For that, you could use the system
clock {systime(1)}, or some such thing you choose. Preserve the seed
using the common block, as above, and then you're all set.

Usually common blocks are frowned upon as a programming technique.
It's a sneaky way of passing information around that bypasses
arguments and keywords. Yet in this case, I think it's justifiable.

M.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: color palette in IDL VM
Next Topic: Re: Is there any way to add texts, lines, wind vector over terrain surface (over IDLgrSurface )?

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

Current Time: Sat Oct 11 10:19:00 PDT 2025

Total time taken to generate the page: 0.64462 seconds