help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about RNGs used in oct files, and multiple instances of Oct


From: Francesco Potortì
Subject: Re: Question about RNGs used in oct files, and multiple instances of Octave
Date: Mon, 02 Jun 2014 02:25:09 +0200

>Francesco Potortì:
>> >If you are using multiple generators in parallel, if at some point
>> >the internal states of some generators become the same, they are now
>> >dependent.  They are perfectly correlated with each other.
>> >
>> >It is also possible for generators to become in step with each other,
>> >which is just as bad (one sequence becomes the other sequence after a
>> >lag).
>> >
>> >I would suggest that if you are running a stochastic program on a
>> >cluster of machines, and need to be sure about randomness, you get
>> >hardware random number generators to generate true random numbers.
>> >If nothing else, they are probably faster (or could be).
>> 
>> From a mathematical point of view, you are right.  From a human point
>> of view, that depends on numbers.  The Mersenne twister used by
>> Octavés rand function has a period of 2^{19937}-1, which is about
>> 1e6000.
>> 
>> Unless I'm mistaken, this means that if you run, say, 1e5 independent
>> generators each choosing a different seed and generating 1e9 random
>> numbers, the collision probability is around 10^-(6000-9-5-5), which
>> is incredibly low.

Ghaverla:
>If someone has the money for a cluster, I think they could afford
>hardware RNGs.  Yes, the Mersenne Twister is a good RNG for most casual
>uses.  I have run across a couple of hints that it isn't perfect.

Unless you have cryptographic needs, I see no point in using a hardware
rng.  Unless technology has significantly changed since when I have
looked at hardware generators (say, ten years ago), they are far less
convenient than software rngs for simulation purposes, which is what I
think we are speaking here.

The Mersenne twister is an excellent rng for practically all non
cryptographic uses.  And yes, it is not perfect: no rng is perfect :)

As far as I know, its main drawback is its dimensionality, which may
introduce unwanted correlations if you happen to run simulations where a
single sequence is used to feed hundreds of different independent
sequences of events, rather than using several sequences based on
different feeds.

>Most of my use of the twister is from Perl, as I don't yet understand
>Octave well enough.  And a billion random deviates was somewhere
>between 1 and 12 hours (I was using a bootstrap to change the uniform
>PDF into a non-uniform PDF).

You can easily change my example numbers above to vastly exceed the
computational capabilities of any modern computer, and you still get an
incredibly low collision probability, if that is what you mean.

That said, I am not an expert of rng, and I would be grateful to anyone
who can point to weaknesses in my reasoning.

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it



reply via email to

[Prev in Thread] Current Thread [Next in Thread]