mysqlmathformulaprobabilitypopularity

Formula for showing more liked items more often than less liked items with a random factor


in mysql currently I am using order by RAND() DESC which works fine except i also have a number that counts number of likes which ranges from 0 to 5 right now but 5 could increase in the future let's call 5 my maxlikes

How can order it in such a way that the ones with more likes has more probability of showing up more often but still randomly show the ones with fewer likes from time to time?


Solution

  • You could order by RAND()*likes DESC favors highly liked things
    or something like order by RAND()*maxLikes +Likes DESC add maxLikes/2 on average to rank

    it really depends on what you want the distribution to be I think you could also
    select columns, rankingFormulaWithRandom as rank .... order by rank desc