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

on the prng behind random.random()

Am 19.11.18 um 22:05 schrieb Robert Girault:
> Chris Angelico <rosuav at gmail.com> writes:
>> On Tue, Nov 20, 2018 at 7:31 AM Robert Girault <r at dev.null> wrote:
>>> Nice.  So Python's random.random() does indeed use mt19937.  Since it's
>>> been broken for years, why isn't it replaced by something newer like
>>> ChaCha20?  Is it due to backward compatibility?  That would make sense.
>> What exactly do you mean by "broken"?
> I mean the fact that with 624 samples from the generator, you can
> determine the rest of the sequence completely.

As far as I understand it, this is true only if you see the full 32bit 
output number from the Mersenne Twister for those 624 outputs. If 
however you create a list:

[random.randrange(10) for i in range(624)]

I don't think you can predict what follows.