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 #68610 is a reply to message #68609] Thu, 12 November 2009 13:49 Go to previous messageGo to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
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 16:33:03 PDT 2025

Total time taken to generate the page: 0.24584 seconds