Jump to content

Weighted Randoms


Pezmc

Recommended Posts

I have a mysql query querying my database using order by RAND() LIMIT 1 to sellect a random coice from the database, however I would like to have the chance of a object being chosen increased for certain values (Weighting?)

In my database I have:
[code]
id  name weight
1  Pezm  1
2  Shog  1.1
3  Ebay  1.2
4  PLp  1.3
5  php  1.4
[/code]

So follwing the information in my database if a weighted random script is used php shuld be the most frequent with 1.4*the chance to get chosen, compared to Pezm,

How can this be achieved?
Link to comment
https://forums.phpfreaks.com/topic/34620-weighted-randoms/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.