RE: SHA-based subclass for random module

From: Tim Peters (tim.one_at_comcast.net)
Date: 03/22/04


Date: Mon, 22 Mar 2004 13:41:46 -0500
To: <python-list@python.org>


[David MacQuigg]
> ...
> I'm still curious as to the answer to my very simple and basic
> question:

It is basic, but there's nothing simple about it.

> Are there any examples that show a *non-subjective* difference in a
> physically meaningful result between one PRNG and another?

Yes, but different RNGs have different weaknesses, and whether the
weaknesses of a specific RNG *matter* to you depend on detailed analysis of
the specific app you have in mind.

The primary weakness of linear congruential generators (still the most
common kind) is dramatically illustrated all over the web; e.g., look at the
3D plot at:

    http://www.unf.edu/ccec/cis/CIShtml/RANDUinfo.html

If you need to generate "random" points in 3D space, does it matter that the
particular LCG plotted there systematically generates points that fall on
one of 15 planes, no matter how many points you generate? There's no answer
to that short of analyzing the specifics of what you're trying to accomplish
by generating those points. For example, if your app relies on the triples
generated being approximately equally distributed throughout a 3D cube, that
particular LCG is an obvious disaster for that particular application. But
if your app only cares that the projection of the points onto the x axis is
approximately equally distributed, probably no problem, despite that it's
obvious "by eyeball" that there's nothing even remotely "random" about their
distribution in 3D space.

You're not going to get an easy answer. Well, here's one: the Mersenne
Twister in Python 2.3 is probably the best and most widely tested fast PRNG
in existence now, and has provably good equidistribution properties in high
dimensions (a plot like the one above would have no visible patterns if the
Twister had been used instead).



Relevant Pages

  • please, help me remember the name of this app
    ... No matter how much I look for it, I can't it's name, it was a very simple ... app, that will tell me all the simultaneous keys I have pressed at one ... I guess it's installed as default in every distribution. ...
    (comp.os.linux.misc)
  • Re: Distributing applications
    ... to download a new version of it... ... Being written in python, the app ... Because *all* of the modules are in my custom built distribution, ...
    (comp.lang.python)
  • Re: Tcl and C++
    ... if I have reduced size of distribution from 2.2 Mb to 1.8 Mb I ... At least encoding support in optcl should be fixed. ... instance visualize Word document inside my app. ... important limitation that I have first to save unencrypted content of ...
    (comp.lang.tcl)
  • Re: Tkinter or wxpython?
    ... mean by a "good reason" to write a desktop gui. ... Might or might not matter depending on the application. ... Compared to a desktop app? ...
    (comp.lang.python)
  • Re: Can I distribute Reference Libraries?
    ... > Packager would allow distribution of then app, the runtime, ... and any reference libraries required to support the app. ... distribution rights from the supplying party whether that be Microsoft or a ...
    (microsoft.public.access.devtoolkits)

Loading