Re: Randomu seed initialization [message #68605] |
Fri, 13 November 2009 08:31  |
Conor
Messages: 138 Registered: February 2007
|
Senior Member |
|
|
Thanks for the input guys:
Jeremy:
I've checked in my primary function, and the variable I pass is
uninitialized at first (obviously it becomes initialized after the
first call to randomu() and stays that way). I haven't specifically
checked that it is uninitialized in the subroutine, but the subroutine
is only about 5 lines long, and I'm certainly not initializing it. So
if it is initialized, then that's certainly an IDL bug (and it seems
unlikely to me).
Matt:
I checked this possiblity, by making a couple simple routines:
pro test
print,randomu(seed,1)
test2
end
pro test2
print,randomu(seed,1)
end
Run this and you will get two different answers out - i.e. the random
seed is not initialized to the same value more than once. Which is
why I don't understand what's going on with my routine: conceptually,
this is the simple case of what I'm doing in my routine. This is why
I really wish I knew what randomu() was doing. I'm wondering (and
there are kinda hints to this in the documentation) if there is a
hidden "global" seed, which is initialized by the first call to randomu
(), and used by all subsequent calls to randomu() that have an
uninitialized seed. Either that or the initialization of the seed is
quasi-random each time (which would be much better, IMO).
Chris:
Thanks for the suggestion, that's what I've done for now, and it fixes
it. I just wish I understood what is going on.
Paolo: I could definitely go for some better documentation!
Presumably if it was better documented I would be able to avoid
problems like this, and I would (perhaps) be better able to determine
what I was doing wrong, or if this is a bug. As near as I can
determine I'm using randomu properly (it's not exactly a complicated
function). To uninitialized variables go into two separate calls to
randomu(), and the same random numbers come out both times. Is that
supposed to happen ever?
|
|
|