"Paddy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Brian Quinlan wrote: >> This is less a Python question and more a optimization/probability >> question. Imaging that you have a list of objects and there frequency in >> a population e.g. >> >> lst = [(a, 0.01), (b, 0.05), (c, 0.50), (d, 0.30), (e, 0.04), (f, 0.10)] >> >> and you want to drawn n items from that list (duplicates allowed), with >> that probability distribution.
For a set of probabilities that uneven, you *might* do better to sort high to low and do a linear search. Or check the two common cases and then do a binary search on the rest. tjr -- http://mail.python.org/mailman/listinfo/python-list