random

Tim Peters tim.one at home.com
Wed May 30 04:15:02 EDT 2001


[Bas van Gils]
> For one of my classes (machine learning, actually) I'm going to do an
> experiment. One of the jobs that I should tackle is segmenting a
> dataset. The total set is 10000 items big. First I make a set of 1000
> items, then 2000 etc etc.. Making this set is done by *randomly*
> extracting items from the big set.
>
> One of the things that I'm concerned about is this random-ness. My
> teacher (actually a nice guy :) explained to us that not all
> random-number-generators are "good", and that this selection process
> *must* *be* *random*. So, my question: how random is the
> random-number-generator that python uses?

6.  And if your teacher says he doesn't know how random 6 is, call him an
idiot and walk out in a huff <wink>.

Seriously, it's impossible to answer this without getting an objective
definition of "good" from your teacher.  Python's random.random() is the std
Wichmann-Hill generator, and passes most tests for randomness.  It's
certainly better than the rand() function in the typical C library; it's
certainly worse than, e.g., the Mersenne Twister.

If you want truly random bits, they're available for the asking; for
example, at

    http://www.fourmilab.ch/hotbits/





More information about the Python-list mailing list