Answer the question
In order to leave comments, you need to log in
How to manage post appearance probabilities (rating, sorting, "recommended")?
Main question:
(total number of likes 266,
total number of views: 2199,
total number of posts # 10)
TEMPLATE
(post # - number of likes, number of views)
0 -20, 65
1 - 15 , 200
2 - 10, 20
3 - 40, 150
4 - 35, 89
5 - 30, 100
6 - 22, 80
7 - 12, 15
8 - 50, 980
9 - 32, 500
You need to show 5 posts, but the condition is ;
- The selection of posts should be random.
- There should be a preference for posts with a large number of likesand its ratio with views should also be quite large, but at the same time there should be a small chance of showing posts with fewer likes and views.
In short, how do you make one site slightly less likely to appear and another slightly more likely to appear?
Additional question
How to create such an algorithm (samples of random posts, but with a preference for a higher rating) in PHP?
Answer the question
In order to leave comments, you need to log in
1. read this question How to select a random item from a list based on its weight? , there Nikolai Panaitov gave a good, suitable answer, and this contains 70% of the answer to your question.
2. as a post weight try:
w=c+a*Log(1+лайков[пост])+b*Log(1+просмотров[пост])
a>=0, b>=0, c>=0
are the "adjustment knobs" for your selection. The more a
, the stronger the impact of likes, the more b
, the stronger the impact of views, the more c
, the more "equal opportunities for all."
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question