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 #57831 is a reply to message #57829] Fri, 04 January 2008 01:54 Go to previous messageGo to previous message
wita is currently offline  wita
Messages: 43
Registered: January 2005
Member
The trick is indeed to specify a random seed during the first call to
RANDOMU and preserve the seed value through subsequent calls to
RANDOMU. If you do not specify it in the first call (like in your
example) the seed value will be taken from some system values (like
the systime or similar) and RANDOMU will produce different sets of
random numbers with each call. This is generally undesirable,
if you want your results to be reproducible.

example:
IDL> seed=1
IDL> print, randomu(seed, 10)
0.415999 0.0919649 0.756410 0.529700 0.930436
0.383502 0.653919 0.0668422 0.722660 0.671149
IDL> print, randomu(seed, 10)
0.383416 0.631635 0.884707 0.519416 0.651519
0.237774 0.262453 0.762198 0.753356 0.909208
IDL> seed=1
IDL> print, randomu(seed, 10)
0.415999 0.0919649 0.756410 0.529700 0.930436
0.383502 0.653919 0.0668422 0.722660 0.671149
IDL> print, randomu(seed, 10)
0.383416 0.631635 0.884707 0.519416 0.651519
0.237774 0.262453 0.762198 0.753356 0.909208

Note that while I specify seed=1, it will be replaced by a LONARR(36)
after the first call to RANDOMU.

A more elegant solution without using COMMON blocks is to wrap the
random number generator in an IDL object.

with best regards,

Allard
[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: Fri Oct 10 04:35:55 PDT 2025

Total time taken to generate the page: 0.23968 seconds