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

Home » Public Forums » archive » fun with random numbers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
fun with random numbers [message #19241] Wed, 01 March 2000 00:00
Brian Jackel is currently offline  Brian Jackel
Messages: 34
Registered: January 1998
Member
Greetings

We've just spent a couple hours figuring out why a Monte-Carlo
simulation was giving peculiar (ie. wrong) results.

The "test" procedure creates two random variables and prints
them. Called twice, you might think that the results would be
totally different. Here's an example result:


x 0.120838
y 0.649213 0.577647 0.139354 0.745442

x 0.649213
y 0.577647 0.139354 0.745442 0.942317


The problem is that for the first random number, "seed" is
undefined, so a generic state is used. From the docs:

"In addition to states maintained by the user in variables,
the RANDOMU and RANDOMN functions contain a single shared
generic state that is used if a named variable is not supplied
as the Seed argument or the named variable supplied is undefined.
The generic state is initialized once using the time-of-day, and
may be re-initialized by providing a Seed argument that is a
constant or expression."

Which is all fine. This generic state is used to produce the
first random number, the seed is updated, then apparently used
to overwrite the generic state. Another four random numbers are
produced, with the seed changing every time. However, none
of these values are used to overwrite the generic state.

Consequently, on the next call, we start with a generic state
that is only advanced *one* from the previous call. Hence the
sequence of "y" values starts at the second position of the
previous "y" sequence.

I would assert that this is not good behaviour. The "generic
state" should
1) always be overwritten with the last seed OR
2) should never be changed without an explicit call by the user


Any comments?




============================================================ ===
PRO test

x= RANDOMU(seed,1)
y= RANDOMU(seed,4)
PRINT,'x',x
PRINT,'y',y

RETURN

END

test
test

END
[Message index]
 
Read Message
Previous Topic: SPAWN and windows
Next Topic: 3D thin-plate spline algorithm?

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

Current Time: Sat Oct 11 14:48:30 PDT 2025

Total time taken to generate the page: 1.67768 seconds