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

Home » Public Forums » archive » Re: Randomu seed initialization
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 seed initialization [message #68609 is a reply to message #68605] Thu, 12 November 2009 13:59 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
As a general comment - anybody is wondering how useful
it is to have a poorly documented random number generator
of unknown robusteness and period in IDL?

I mean - all the docs say is that's "similar" to ran1
in numerical recipes - how similar? I mean - either
it is ran1 or it isn't :) if not, what? - and if it
is identical to ran1 - then we should know.

Also it's not clear to me what the seed really is -
seems overly complicated.

So I have had enough.

A while ago I decided to write my own random number
generator based on numerical recipes edition 3 - it's
much slower but very robust, and even though I
may not actually *need* such a good random number
generator, at least it's not a black box!

You can call it with a single integer seed or with 3 UL64's
- internally the seed is just 3 ulong64numbers - much
simpler then the seed from randomu :)

IDL> seed=17 & print,pg_ran(seed,10,/double)
0.014634145 0.40536879 0.88335246 0.92373509
0.26807163 0.084861013 0.38462108 0.75499700
0.0081408007 0.43871562
IDL> help,seed
SEED ULONG64 = Array[3]


See header documentation for more info.

http://hea-www.cfa.harvard.edu/~pgrigis/idl_stuff/pg_ran.pro

Ciao,
Paolo

On Nov 12, 4:49 pm, Chris <beaum...@ifa.hawaii.edu> wrote:
> On Nov 12, 10:32 am, sav...@nsidc.org wrote:
>
>
>
>> Jeremy Bailin <astroco...@gmail.com> writes:
>>> If I had to speculate, I'd say that the variable that you're passing
>>> as the seed isn't undefined like you think it is. Have you tried doing
>>> a "help, seed" right before the randomu call?
>
>> If I was going to speculate, I would guess the undefined seed gets set
>> to the same value internally every time.  Thereby starting the same
>> string of pseudo-random numbers.
>
>> I usually use:
>>   seed = long(systime(/seconds) )
>
>> To initialize my seed. It's not perfect, but it's a start.
>
>> Also remember from the docs: "Each independent random number sequence
>> should maintain its own state variable. To maintain a state over
>> repeated calls to a procedure, the seed variable may be stored in a
>> COMMON block."
>
>> Matt
>
>> --
>> Matthew Savoie  -  Scientific Programmer
>> National Snow and Ice Data Center
>> (303) 735-0785 http://nsidc.org
>
> I've hit this issue before - calling RANDOMU with an undefined seed
> many times produces collections of random numbers with very similar
> properties. It's weird.
>
> Successive calls to randomu which save the seed value avoid this
> problem. Whenever I use randomu in a function, I do something like
>
> function junk
> common junk_seed, seed
> x = randomu(seed)
> return, x
> end
>
> which keeps track of the seed value automatically.
>
> chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how smooth surface
Next Topic: Randomu() behavior - BAD!

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

Current Time: Fri Oct 10 01:18:35 PDT 2025

Total time taken to generate the page: 1.59755 seconds