Created
October 3, 2021 00:05
-
-
Save hunterwilhelm/1a63162028a69d13fb27e21aff4276f7 to your computer and use it in GitHub Desktop.
The least disliked ranking algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Dislike Total (DT) is calculated | |
// by totaling the below 'mean' differences. | |
// The lowest DT is the winner. | |
function calcLeastDisliked(multiArray) { | |
const sum = array=>array.reduce((a,b)=>a + b, 0); | |
const singleArray = [].concat(...multiArray); | |
const avg = sum(singleArray) / singleArray.length; | |
return multiArray.map(ratings=>{ | |
const belowAvgRatings = ratings.filter(x=>avg > x, ratings); | |
const DT = avg * belowAvgRatings.length - sum(belowAvgRatings); | |
console.log(ratings, DT); | |
return DT; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why?
When people are voting on things, a popular vote usually ends up with a polarized outcome. Some people will really love it and others will hate it. This algorithm takes into account that we want the thing that is mostly okay with everybody.
Example
returns
[0.375, 1.75, 9.5, 2.75]
prints