Answer the question
In order to leave comments, you need to log in
What is the best algorithm to control the probability of a random sample from an array?
Greetings!
There is such an interesting task that my programmer can’t master something in any way:
on my website (construction portal) they decided to introduce something like their own teaser network ...
writing it was no problem, but here’s where the stop happened: the
probability of showing We decided to make ads the product of ctr and the cost per click entered by the advertiser (according to the Google system, the intersection of a high cost per click and a high quality of an ad wins) ...
But here's how to effectively and correctly implement such ad selection control, until we could finish it ...
I would be grateful for any advice! !! :)
Answer the question
In order to leave comments, you need to log in
If the ad base in MySQL and ads is not very large, then it can be something like this:
SELECT ... ORDER BY ctr * price + RAND ()
where x is some coefficient
Let me suggest a heavy mathematical solution:
1) normalization and at the same time definition of RND() boundaries for each declaration: ( LEFT[i]; LEFT[i+1] )
NORM=0
for i=0 to N-1
LEFT[i] = NORM
NORM = NORM + CTR[i]*PRICE[i]
2) work
ADV_ID = GET_i_BY_LEFT_BORDER( RND()*NORM )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question