Which algorithm is better to control the probability of randomly sampling from an array?
There is such an interesting problem that my programmer something does not overpower:
I have on site (construction site) decided to implement something like your teaser online...
to write it of problems was not, but that's what happened stopper:
the probability of the ad decided to do the work of ctr and price per click entered by the advertiser (for system Google wins the intersection of high click prices and high quality ads)...
But how to effectively and correctly implement this control sample ads, yet could not doperet...
I would be grateful for any advice!!! :)
asked October 8th 19 at 03:36
If ad database in MySQL and ads is not very much, it is possible approximately so:
SELECT... ORDER BY ctr*price+RAND()
where x is some ratio
Will allow us to offer heavy mathematical solution:
1) normalization and at the same time defining the boundaries of the RND() for each advertisement: ( LEFT[i]; LEFT[i+1] )
for i=0 to N-1
LEFT[i] = NORM
NORM = NORM + CTR[i]*PRICE[i]
ADV_ID = GET_i_BY_LEFT_BORDER( RND()*NORM )
ORDER BY RAND () is the simplest, but very slow for large tables, it is also worth considering.
Find more questions by tags Random numbersDatabase administrationDatabases