on the prng behind random.random()

Dan Sommers 2QdxY4RzWzUUiLuE at potatochowder.com
Mon Nov 19 19:07:47 EST 2018


On 11/19/18 6:49 PM, Robert Girault wrote:

 > I think I disagree with your take here.  With mt19937, given ANY seed,
 > I can eventually predict all the sequence without having to query the
 > oracle any further.

Even if that's true, and I use mt19937 inside my program, you don't
[usually|necessarily] have access to the raw output from it.

 > If you're just writing a toy software, even K&R PRNG works just fine.
 > If you're writing a weather simulation, I suppose you need real
 > random-like properties and still need your generator to be reproducible.
 > If you're using random Quicksort, you do need unpredictability and
 > reproducibility.  If you're writing a crypto application, then you need
 > something way stronger.  We need all of them ...

Agreed.  Mostly.  IIRC, though, your question was about *replacing*
mt19937, not adding a new RNG.

Please use the right tool for the job at hand.

 > ... But mt19937 is now useful only in toy software.

It has "real random-like" properties (for certain definitions of "real"
and "random-like") and it's reproducible.  Therefore, it's good for
weather simulations, too.



More information about the Python-list mailing list