Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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: UNSURE 0.410 X-Spam-Level: **** X-Spam-Evidence: '*H*': 0.37; '*S*': 0.19; 'question.': 0.14; 'fruit': 0.16; 'set,': 0.16; 'example': 0.22; 'header:User-Agent:1': 0.23; 'choices': 0.24; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'sets': 0.30; 'acceptable': 0.36; 'should': 0.36; 'jason': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'above,': 0.60; 'pick': 0.64; 'chance': 0.65; 'dict()': 0.84; 'pardon': 0.84; 'received:195.238': 0.84; 'received:195.238.6': 0.84; 'received:belgacom.be': 0.84; 'received:isp.belgacom.be': 0.84 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBABe4LFJbs/yG/2dsb2JhbAANTcMkgnOBOoMaAQEEOEARCyEWDwkDAgECAUUTCAK8VYlAiCSQBxaEBwOXdZUI Date: Sun, 08 Sep 2013 19:48:55 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130704 Icedove/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Weighted choices References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Sun, 08 Sep 2013 20:35:32 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378665333 news.xs4all.nl 15905 [2001:888:2000:d::a6]:32967 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53848 Op 08-09-13 04:12, Jason Friedman schreef: > choices = dict() > choices["apple"] = 10 > choices["pear"] = 20 > choices["banana"] = 15 > choices["orange"] = 25 > choices["kiwi"] = 30 > > I want to pick sets of fruit, three in a set, where the chance of > selecting a given fruit is proportional to its weight. In the example > above, pears should appear twice as often as apples and kiwis should > appear twice as often as bananas. Just a small question. Is a set of three bananas an acceptable outcome? -- Antoon Pardon