Seeded Random
Posted: Sat Oct 06, 2012 12:27 pm
Hi,
So, I had a previous post here: viewtopic.php?f=1&t=136014 about random not being really random.
Now, I have been looking to make this a better random and now I have a setup ready. Basically, I have a table with 2445 rows and I am taking 5 random rows out of it. Simply, I just do:
SELECT...ORDER BY RAND() LIMIT 5
Each row has a "plays" count, and every time a show gets selected, it gets a +1 to its plays count.
Now, I want to use this "plays" field to seed my random select. I would like rows that have the lowest number of "plays" to be more likely (seeded in their favor) to be selected. That is not to say that the higher number rows couldn't be selected, but just that the higher the number, the less likely it is to be selected.
To be honest, I have no idea how to do this. I have only used built in random functions without any weighting. Can anyone point me in the right direction with this? It can be in PHP or in SQL, or a combo of both.
So, I had a previous post here: viewtopic.php?f=1&t=136014 about random not being really random.
Now, I have been looking to make this a better random and now I have a setup ready. Basically, I have a table with 2445 rows and I am taking 5 random rows out of it. Simply, I just do:
SELECT...ORDER BY RAND() LIMIT 5
Each row has a "plays" count, and every time a show gets selected, it gets a +1 to its plays count.
Now, I want to use this "plays" field to seed my random select. I would like rows that have the lowest number of "plays" to be more likely (seeded in their favor) to be selected. That is not to say that the higher number rows couldn't be selected, but just that the higher the number, the less likely it is to be selected.
To be honest, I have no idea how to do this. I have only used built in random functions without any weighting. Can anyone point me in the right direction with this? It can be in PHP or in SQL, or a combo of both.