Re: Most pythonic way of weighted random selection

2008-08-30 Thread Steven D'Aprano
On Sat, 30 Aug 2008 17:41:27 +0200, Manuel Ebert wrote: > Dear list, > > who's got aesthetic advice for the following problem? ... [ugly code removed] > Now that looks plain ugly, and I wonder whether you might find a > slightly more elegant way of doing it without using numpy and the like. N

Re: Most pythonic way of weighted random selection

2008-08-30 Thread duncan smith
Manuel Ebert wrote: > Dear list, > > who's got aesthetic advice for the following problem? I've got some > joint probabilities of two distinct events Pr(X=x, Y=y), stored in a > list of lists of floats, where every row represents a possible outcome > of X and every float in a row a possible outcom

Re: Most pythonic way of weighted random selection

2008-08-30 Thread bearophileHUGS
Manuel Ebert, this may be related/useful: http://code.activestate.com/recipes/498229/ Note that numpy has a bisection method/function that are probably quite faster. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Most pythonic way of weighted random selection

2008-08-30 Thread Manuel Ebert
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear list, who's got aesthetic advice for the following problem? I've got some joint probabilities of two distinct events Pr(X=x, Y=y), stored in a list of lists of floats, where every row represents a possible outcome of X and every float in a