Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53848

Re: Weighted choices

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 <antoon.pardon@rece.vub.ac.be>
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 <antoon.pardon@rece.vub.ac.be>
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 <CANy1k1gHFFgd82P5VZJEEZvWe_kHJvi2r1uqVh3Sr=nFZyazuQ@mail.gmail.com>
In-Reply-To <CANy1k1gHFFgd82P5VZJEEZvWe_kHJvi2r1uqVh3Sr=nFZyazuQ@mail.gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.157.1378665333.5461.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Weighted choices Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-08 19:48 +0200

csiph-web