Sorting A List Of Songs By Popularity

后端 未结 2 1480
感动是毒
感动是毒 2021-02-04 14:10

For student council this year, I\'m on the \"songs\" committee, we pick the songs. Unfortunately, the kids at the dances always end up hating some of the stupid song choices. I

相关标签:
2条回答
  • 2021-02-04 14:29

    That's a very good question. There are a few similar questions that have been asked here.

    This article is probably a good place to start. Apparently upvotes minus downvotes is a bad way to do it. The better way is to use complicated maths to assign a score to each and sort by that.

    Here is a scoring function in Ruby from the article:

    require 'statistics2'
    
    def ci_lower_bound(pos, n, power)
        if n == 0
            return 0
        end
        z = Statistics2.pnormaldist(1-power/2)
        phat = 1.0*pos/n
        (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
    end
    

    pos is the number of positive rating, n is the total number of ratings, and power refers to the statistical power: pick 0.10 to have a 95% chance that your lower bound is correct, 0.05 to have a 97.5% chance, etc.

    As a usability thing, I would sort the data by the score, but I would not show the score to the user. I would only show the number of upvotes and downvotes.

    0 讨论(0)
  • 2021-02-04 14:51

    How about sorting songs by posting time or number of votes (negative + positive)? If your goal is to give every song equal attention, this sounds good enough.

    0 讨论(0)
提交回复
热议问题