#include Global $Apps[21][4] = [ _ [20, 0, 0, 0], _ ; Number Of Apps, Nothing, Nothing, Nothing. [100, 0, 10, 0], _ ; Anonymous + Votes, Anonymous - Votes, Registered + Votes, Registered - Votes. [200, 0, 20, 0], _ [500, 0, 50, 0], _ [1000, 0, 100, 0], _ [100, 10, 10, 1], _ [200, 20, 20, 2], _ [500, 50, 50, 5], _ [1000, 100, 100, 10], _ [100, 30, 10, 3], _ [200, 60, 20, 6], _ [500, 150, 50, 15], _ [1000, 300, 100, 30], _ [100, 50, 10, 5], _ [200, 100, 20, 10], _ [500, 250, 50, 25], _ [1000, 500, 100, 50], _ [100, 100, 10, 10], _ [200, 200, 20, 20], _ [500, 500, 50, 50], _ [1000, 1000, 100, 100]] Global $Print[$Apps[0][0]][9] For $A = 1 To $Apps[0][0] $Print[$A - 1][0] = $Apps[$A][0] $Print[$A - 1][1] = $Apps[$A][1] $Print[$A - 1][2] = $Apps[$A][2] $Print[$A - 1][3] = $Apps[$A][3] $Print[$A - 1][4] = _WilsonPopularity($A) & " %" $Print[$A - 1][5] = _BayesPopularity($A) & " %" $Print[$A - 1][6] = _LupoPopularity($A) & " %" $Print[$A - 1][7] = Round(($Apps[$A][0] / ($Apps[$A][0] + $Apps[$A][1])) * 100, 1) & " %" $Print[$A - 1][8] = Round((($Apps[$A][0] - $Apps[$A][1]) / ($Apps[$A][0] + $Apps[$A][1])) * 100, 1) & " %" Next _ArrayDisplay($Print, "Rating", -1, 0, "", "|", "n|u+|u-|r+|r-|Wilson|Bayes|Lupo|+/tot|+--/tot") Func _WilsonPopularity($N = 1) #cs Popularity = (p + z * z / (2 * n) - z * Sqrt((p * (1 - p) + z * z / (4 * n)) / n)) / (1 + z * z / n) p = fraction of the positive ratings n = total number of votes z = the (1 - alpha/2) percentile of the standard normal distribution Notes: - increase "z" to require an higher number of votes to be popular #ce Local $cPopularity, $cP, $cZ, $cN, $cPositive, $cNegative $cPositive = $Apps[$N][0] + 10 * $Apps[$N][2] $cNegative = $Apps[$N][1] + 10 * $Apps[$N][3] $cP = $cPositive / ($cPositive + $cNegative) $cN = $cPositive + $cNegative $cZ = 15 $cPopularity = ($cP + $cZ * $cZ / (2 * $cN) - $cZ * Sqrt(($cP * (1 - $cP) + $cZ * $cZ / (4 * $cN)) / $cN)) / (1 + $cZ * $cZ / $cN) Return Round($cPopularity * 100, 1) EndFunc Func _BayesPopularity($N = 1) #cs Popularity = ((avg_num_votes * avg_rating) + (this_num_votes * this_rating)) / (avg_num_votes + this_num_votes) avg_num_votes = average number of votes for all software = (num_votes_software_1 + num_votes_software_2 + ...) / num_software avg_rating = average rating of all software = (rating_software_1 + rating_software_2 + ...) / num_software this_num_votes = number of votes for this software = positive_votes + negative_votes this_rating = rating of this software = (positive_votes - negative_votes) / (positive_votes + negative_votes) Notes: - do not update rating each query, but only each user vote - eventually ratings could be updated periodically (e.g. everyday) #ce Local $cPopularity, $cTotalVotes, $cTotalRating, $cVotes, $cRating, $cPositive, $cNegative For $A = 1 To $Apps[0][0] $cPositive = $Apps[$A][0] + 10 * $Apps[$A][2] $cNegative = $Apps[$A][1] + 10 * $Apps[$A][3] $cTotalVotes += $cPositive + $cNegative $cTotalRating += ($cPositive - $cNegative) / ($cPositive + $cNegative) Next $cTotalVotes /= $Apps[0][0] $cTotalRating /= $Apps[0][0] $cPositive = $Apps[$N][0] + 10 * $Apps[$N][2] $cNegative = $Apps[$N][1] + 10 * $Apps[$N][3] $cVotes = $cPositive + $cNegative $cRating = ($cPositive - $cNegative) / ($cPositive + $cNegative) $cPopularity = (($cTotalVotes * $cTotalRating) + ($cVotes * $cRating)) / ($cTotalVotes + $cVotes) Return Round($cPopularity * 100, 1) EndFunc Func _LupoPopularity($N = 1) #cs Popularity = 0.8 * (0.8 * Value1 + 0.2 * Value2) + 0.2 * (0.8 * Value3 + 0.2 * Value4) Value1 = positive / tot (anonymous) Value2 = positive / max positive (anonymous) Value3 = positive / tot (registered) Value4 = positive / max positive (registered) #ce Local $cPopularity, $cMaxVotes, $cValue1, $cValue2, $cValue3, $cValue4 $cValue1 = $Apps[$N][0] / ($Apps[$N][0] + $Apps[$N][1]) For $A = 1 To $Apps[0][0] If $Apps[$A][0] > $cMaxVotes Then $cMaxVotes = $Apps[$A][0] EndIf Next $cValue2 = $Apps[$N][0] / $cMaxVotes $cValue3 = $Apps[$N][2] / ($Apps[$N][2] + $Apps[$N][2]) For $A = 1 To $Apps[0][0] If $Apps[$A][2] > $cMaxVotes Then $cMaxVotes = $Apps[$A][2] EndIf Next $cValue4 = $Apps[$N][2] / $cMaxVotes $cPopularity = 0.8 * (0.8 * $cValue1 + 0.2 * $cValue2) + 0.2 * (0.8 * $cValue3 + 0.2 * $cValue4) Return Round($cPopularity * 100, 1) EndFunc