Mark Dickinson <dicki...@gmail.com> added the comment:

The nonuniformity of randrange has a knock-on effect in other random module 
functions.  For example, take a sample of 100 elements from 
range(6004799503160661), and take the smallest element from that sample.  Then 
the exact distribution of that smallest element is somewhat complicated, but 
you'd expect it to be even with probability very close to 50%.  But it turns 
out that it's roughly twice as likely to be even as to be odd.

>>> from random import sample
>>> from collections import Counter
>>> population = range(6004799503160661)
>>> Counter(min(sample(population, 100)) % 2 for _ in range(100000))
Counter({0: 66810, 1: 33190})

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9025>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to