choosing random numbers with weights/probability?
Al Christians
achrist at easystreet.com
Tue Jun 22 13:04:35 EDT 1999
It looks like generating the random number takes much longer than
searching a short list, so that the method I described, which takes
two or more random numbers per selection, is a big loser on speed
unless one is searching a list of 100 elements or more. I think
it might be better for statistical properties of the results,
depending on lots of things (the magnitudes of the weights and
the quality of the rng), but in simple applications, that probably
doesn't matter much, and IDK for sure.
Al
Darrell wrote:
>
> Orig:
> Time: 10.28 sec
> {'one': 25167, 'two': 25144, 'three': 49689}
>
> Terry's:
> Time: 9.94 sec
> {'one': 24983, 'three': 50020, 'two': 24997}
>
> --
> --Darrell
More information about the Python-list
mailing list