Re: RANDOMU not very random [message #39859] |
Fri, 18 June 2004 09:24 |
ian
Messages: 26 Registered: February 1992
|
Junior Member |
|
|
David Fanning <davidf@dfanning.com> wrote in message news:<MPG.1b3a78d5e8ddf9719897a3@news.frii.com>...
> Ian Chapman writes:
>
>> A colleague and I are working on simulating cosmic glitches in
>> interferograms. The way we are trying to accomplish this is assigning
>> each point in an interferogram a random number using IDL's RANDOMU.
>> Once the random number falls below a specified threshold, we insert a
>> cosmic ray.
>>
>> We originally used an undefined seed to get the random numbers, but we
>> quickly discovered that if we ran the routine over and over again, the
>> random numbers shifted by 1 position each time. We corrected this by
>> defining our seed using the SYSTIME function. Now, however, we find
>> that if you run the program a number of times, you see the same
>> positions popping up (not in an identifiable pattern, but they show up
>> more often than you would expect).
>>
>> For example, Cosmic rays in ifgm1 appeared at pts 107 and 534. After
>> running the program ~20 more times, these same points popped up. This
>> seems to happen fairly frequently over long times of many runs.
>>
>> Is there anything that we can do to introduce more randomness into the
>> procedure? Are there any fixes for the IDL random number generators?
>
> Oh, oh. Are you storing the seed somewhere safe between
> calls to your program? You should be. :-)
>
> Once set, you shouldn't be changing it if you want
> a truly (pseudo) random sequence.
>
> Cheers,
>
> David
Originally, we were generating a new seed each time we ran the
program. We then tried running the cosmic ray generator in a loop
with a new seed being generated in each run through the loop. We
still had a problem there.
Now, we run the loop, but make the seed using the systime command only
once outside the loop. This approach seems to work fine.
This behavior seems pretty odd (especially when we were running the
program numerous times by hand and getting similar results popping up
every once in a while).
Oh well, it works alright now. :)
|
|
|
Re: RANDOMU not very random [message #39868 is a reply to message #39859] |
Wed, 16 June 2004 15:34  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ian Chapman writes:
> A colleague and I are working on simulating cosmic glitches in
> interferograms. The way we are trying to accomplish this is assigning
> each point in an interferogram a random number using IDL's RANDOMU.
> Once the random number falls below a specified threshold, we insert a
> cosmic ray.
>
> We originally used an undefined seed to get the random numbers, but we
> quickly discovered that if we ran the routine over and over again, the
> random numbers shifted by 1 position each time. We corrected this by
> defining our seed using the SYSTIME function. Now, however, we find
> that if you run the program a number of times, you see the same
> positions popping up (not in an identifiable pattern, but they show up
> more often than you would expect).
>
> For example, Cosmic rays in ifgm1 appeared at pts 107 and 534. After
> running the program ~20 more times, these same points popped up. This
> seems to happen fairly frequently over long times of many runs.
>
> Is there anything that we can do to introduce more randomness into the
> procedure? Are there any fixes for the IDL random number generators?
Oh, oh. Are you storing the seed somewhere safe between
calls to your program? You should be. :-)
Once set, you shouldn't be changing it if you want
a truly (pseudo) random sequence.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|