I want to randomly pick one of a number of values, with given probability for each 
item, e.g.

abc 50%
def 25%
ghi 25%

The obvious way is to take a list where the 50% item is given twice and then randomly 
pick one, but what if I want to use a probability of 51.3% (and don't tell me of a 
list with 1000 entries and 513 times the 'abc' item *g*).

This seems to be trivial, but I just can't think of a simple and proper way to do it.

Any ideas?


Gunther E. Biernat

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to