General
| From: | Gunther E. Biernat | Date: | Fri, 08 Mar 2002 10:34:13 +0000 |
| Subject: | General | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87749@lists.php.net to get a copy of this message | ||
Guys,
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?
Regards,
Gunther E. Biernat