Is there a better way of doing this?

mattia gervaz at
Fri Mar 6 23:13:43 CET 2009

Il Fri, 06 Mar 2009 18:46:44 -0300, andrew cooke ha scritto:

> i have not been following this discussion in detail, so someone may have
> already explained this, but it should not be necessary to actually
> construct the roulette wheel to select values from it.  what you are
> doing is selecting from a list where the there are different
> probabilities of selecting different entries.  i am pretty sure that can
> be done more efficiently than by constructing a new list with many more
> entries whose aim is to simulate that (which is what the roulette wheel
> seems to be in your code, if i have understood correctly).
> more precisely, i think you can adapt the trick used to select a line at
> random from a file by scanning the file just once.
> sorry if i have misunderstood,
> andrew

Well, I believe that using the right distribution I can for sure find a 
better way for doing the roulette wheel selection. When I'll have enough 
time I'll pick up my statistics book.

More information about the Python-list mailing list