Biased random?
Robert Kern
robert.kern at gmail.com
Mon Aug 27 19:02:58 EDT 2007
Jun-geun Park wrote:
> Ivan Voras 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?
>
> That's weird. random.randint(a,b) will be enough for most cases. Test
> your system to see the distribution is uniform with something like:
The distribution is uniform. However, he wants a way to get non-uniform sampling
of that list.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list