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

Home » Public Forums » archive » Re: Randomu() behavior - BAD!
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: Randomu() behavior - BAD! [message #68597 is a reply to message #68595] Fri, 13 November 2009 12:43 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Conor writes:

> So I did a simple test and have a better idea of how the seed
> initialization works with randomu(). In my mind, this is not good
> news!

I've written a new RandomNumberGenerator object this morning
that may get around some of these problems. (And avoid
common blocks, too!) You can find it here:

http://www.dfanning.com/programs/randomnumbergenerator__defi ne.pro

There are probably any number of way you could use
this object, but here is one possibility. You could
create a new system variable that would be able to give
you random numbers on demand. The seed is always maintained
properly, so that the random number sequence will not repeat
in your lifetime. ;-)

IDL> DefSysV, !RNG, Obj_New('RandomNumberGenerator')
IDL> Print, !RNG -> GetRandomNumbers(3)
0.089239137 0.77428782 0.069180504

You can set the initial seed, but if you don't, the number
of seconds after 1 January 1970 is used. The random sequence
will continue for as long as the object is alive in the IDL
session.

You could create this object and system variable, for example,
in your IDL startup script, and then any program you wrote
could access it.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Save a linkedlist?
Next Topic: Function as variable issue but in own file

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

Current Time: Fri Oct 10 01:45:50 PDT 2025

Total time taken to generate the page: 1.28256 seconds