1

I have a list of { keyword: [low, high], keyword1: [low1, high1], keyword2: [low2, high2] ... } and I would like to run a weighted random algorithm over it to select a keyword for every request. Would the straightforward algorithm skew the results in anyway ?

Thanks, Raja.

Raja
  • 442
  • 5
  • 17
  • What do you mean by "the straightforward algorithm"? Also, what does "low, high" mean? – biziclop Oct 22 '12 at 11:32
  • For a given keywordi, what does lowi and highi represent? – Andrew Tomazos Oct 22 '12 at 11:37
  • low - can be assumed as a min. dollar value ( integer ) this keyword would fetch and similarly high - is a max. dollar value ( integer ) this keyword will fetch. Straight forward algo is - generate a random number between the global high and global low and then select the keyword sample which has this rand in between. Now if there are multiple, again randomly select from that particular list. – Raja Oct 22 '12 at 11:47
  • 1
    Well, that doesn't sound very straightforward to me, unless `low(i) = high(i-1)` for every `i`. Normally what you want is to use the interval sizes (`high(i) - low(i)`) as weights and generate a weighted random number using this: http://stackoverflow.com/questions/1761626/weighted-random-numbers – biziclop Oct 22 '12 at 12:00

0 Answers0