S
S
solomonych2012-02-12 20:15:32
Database
solomonych, 2012-02-12 20:15:32

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

3 answer(s)
S
ShouldNotSeeMe, 2012-02-12
@ShouldNotSeeMe

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

A
Andrew, 2012-02-12
@OLS

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 )

1
1x1, 2012-02-13
@1x1

ORDER BY RAND () is the simplest, but very slow for large tables, this should also be taken into account.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question