Forum Moderators: coopster

Message Too Old, No Replies

Selecting a record on a random, but weighted, basis

selecting a random but weighted record

         

Tourex

4:53 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Hi

I have a table containing details of prizes in a raffle. The raffle is promoted through a banner on every page of the site. Each page impression features details of a different prize, selected by random key.

Now, I want to give extra promotion to prizes worth the most. So, for example, I want Prize A, worth $100, to get 10 times more promotion (page displays) than Prize B worth $10. The prize value is available in a column in the table of course.

Has anybody got any thoughts on how I can achieve this?

Thanks in anticipation.

mcibor

6:39 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only method I can think of now is making the number 100 more probable. You can achieve that selecting random number from 0 to 100 and then checking 0 < no < 9 then 10; 10 < no < 100 then 100; This way 100 will appear 9 times more often. However this method fails if there are other prices (it's useless then).

Sorry for not giving you a good answer. If I arrive at some other solution, then I'll let you know.

Best regards
Michal Cibor