Instatiable Pseudo-Random Number Generator

Joachim Strömbergson Joachim at Strombergson.com
Thu Sep 10 07:37:31 EDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aloha!

Hans Georg Schaathun wrote:
> Can anyone recommend a PRNG which supported multiple instances
> with independent states, and that also can return numpy.array (or 
> something similar) efficiently?
> 
> The distribution is currently Gaussian.

Do the PRNG need to support Gaussian directly, or can you live with a
good uniform distribution? If uniform is ok then any good stream cipher
implementation should do the trick. Or a block cipher in a stream cipher
mode, for example AES in CTR mode.

If you need a pure Python implementation I have one such implementation
of the Snow stream cipher:

http://www.strombergson.com/files/snow.py.gz
http://en.wikipedia.org/wiki/SNOW

You can instantiate as many Snow objects as you need, each with their
own state. On my laptop I get about 300 kByte/s, is that too slow for
your application?

- --
Med vänlig hälsning, Yours

Joachim Strömbergson - Alltid i harmonisk svängning.
========================================================================
Kryptoblog - IT-säkerhet på svenska
http://www.strombergson.com/kryptoblog
========================================================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqo5PsACgkQZoPr8HT30QGQZgCgp3FcOJ1VbP03kGIMFVTkZgHb
el0AoO5bavQCfeyXX5RFlb7dVvWBOl2O
=s0eq
-----END PGP SIGNATURE-----



More information about the Python-list mailing list