How to make Python run as fast (or faster) than Julia

Christian Gollwitzer auriocus at gmx.de
Tue Feb 27 03:08:39 EST 2018


Am 27.02.18 um 03:27 schrieb Chris Angelico:
> On Tue, Feb 27, 2018 at 12:57 PM, bartc <bc at freeuk.com> wrote:
>>
>> Anyway, even this pure Python version can deliver pseudo random numbers at
>> some 200,000 per second, while the built-in generator does 450,000 per
>> second, so it's not bad going.
> 
> The built-in generator is using a completely different algorithm
> though, so rate of generation isn't the entire story. How long is the
> period of the one you're using? (How long before it loops?) If you
> churn the generator to an arbitrary number and then take the next 100
> values it generates, are they randomly distributed? 

George Marsaglia is a researcher who invented a couple of PRNGs which 
are both simple (one of the first was called KISS) yet surprisingly 
good. See here: https://en.wikipedia.org/wiki/KISS_(algorithm)

They possess all these desirable properties you mention above and pass 
the DIEHARD random number generator tests (also invented by Marsaglia).

> Can you
> reconstruct the RNG's internal state by watching it generate numbers
> for a short while?

https://eprint.iacr.org/2011/007.pdf

> Obviously no PRNG is going to be perfect at this, but there are
> certainly degrees of quality to be compared.

It is a field of research and the generator shown by Bart is one of the 
better generators constructed by an expert in the field.

	Christian



More information about the Python-list mailing list