Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:module': 0.04; 'python)': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:python': 0.10; "'a'": 0.16; 'skip:3 30': 0.16; 'subject:between': 0.16; 'subject:random': 0.16; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'rid': 0.29; 'skip:1 30': 0.29; 'seem': 0.29; '(and': 0.30; 'subject:?': 0.31; 'accuracy': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.34; '(not': 0.35; 'to:addr:python-list': 0.35; 'something': 0.35; 'received:org': 0.36; '8bit%:86': 0.37; 'acceptable': 0.37; 'but': 0.37; 'skip:_ 10': 0.38; 'to:addr:python.org': 0.40; 'your': 0.61; 'skip:1 10': 0.63; 'results': 0.64; 'skip:\xd0 20': 0.77; 'obtained': 0.80; 'skip:1 20': 0.82; 'received:88.154': 0.84; 'notorious': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: difference between random module in python 2.6 and 3.2? Date: Tue, 07 Feb 2012 12:05:35 +0200 References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 88.154.238.165 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120130 Thunderbird/10.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 9 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328609155 news.xs4all.nl 6962 [2001:888:2000:d::a6]:52532 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19952 07.02.12 00:06, Matej Cepl написав(ла): > return seq[int(random.random() * len(seq))] > > doesn't seem like something so terrible (and maintenance intense). :) _choice('abc') returns 'a' with probability P('a') = 1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with probability P('b') = 3002399751580331/9007199254740992 = 1/3 + 1/27021597764222976. P('b') - P('a') = 1/9007199254740992. This may be acceptable for your application, but for applications that are concerned not only about the repeatability of results, but the accuracy and consistency with the results obtained by other (not Python) applications, it is better to get rid of such a notorious bias.