I have a website where users can post and vote on offers. On the first page, I initially list 10 sentences, and the title selects a new random sentence every 7 seconds.
I want the votes to influence the likelihood of a sentence appearing, both in a list of 10 sentences and in a sentence of a headline. For this, I have a small algorithm for calculating popularity, taking into account voices, age and a couple of other things (many settings are required).
In any case, after starting the algorithm, I have a dictionary of sentences and popularity index, sorted by popularity:
{ S = Suggestion1, P = 0.86 } { S = Suggestion2, P = 0.643 } { S = Suggestion3, P = 0.134 } { S = Suggestion4, P = 0.07 } { S = Suggestion5, P = 0.0 } { . . .}
I do not want this to be an illustrious view, so I would like to introduce some random element into the selection process.
In short, I would like popularity to be the probability that an offer is selected from a list .
With a complete list of offers / popularity, how do I go for a choice of 10 based on probabilities? How can I apply the same to the loop header clause?
source share