➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 mark.dickinson
收信人 mark.dickinson, rhettinger
日期 2010-06-18.13:47:11
SpamBayes Score 0.010246534
Marked as misclassified 否
Message-id <1276868834.9.0.0441513946777.issue9025@psf.upfronthosting.co.za>
In-reply-to
内容
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})
历史
日期 用户 动作 参数
2010-06-18 13:47:15mark.dickinson修改recipients: + mark.dickinson, rhettinger
2010-06-18 13:47:14mark.dickinson修改messageid: <1276868834.9.0.0441513946777.issue9025@psf.upfronthosting.co.za>
2010-06-18 13:47:12mark.dickinson链接issue9025 messages
2010-06-18 13:47:11mark.dickinson创建