Biased random?

ChrisHulan chris.hulan at
Tue Aug 28 14:41:26 CEST 2007

On Aug 27, 4:42 pm, Ivan Voras <ivoras at __fer.hr__> wrote:
> Hi,
> I have a list of items, and need to choose several elements from it,
> "almost random". The catch is that the elements from the beginning
> should have more chance of being selected than those at the end (how
> much more? I don't care how the "envelope" of probability looks like at
> this point - can be linear). I see that there are several functions in
> Python standard libraries for various distribution, but is there an easy
> pythonic way to make them do what I need?

Not sure how pythonic it is...but a simple(?) way to increase the
chances for particular
elements is to introduce copies. For example given [1,2,3], you can
increase the chances
of selecting '1' by changing the list to [1,1,2,3].


More information about the Python-list mailing list