Last active
August 29, 2015 14:01
-
-
Save frankbi/7da5399f46ee5c99e3ba to your computer and use it in GitHub Desktop.
Revisions
-
frankbi revised this gist
May 6, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,8 @@ function getSpearmanRankCorrelation(list_x, list_y) { summation += Math.pow((sorted_x[i][1] - sorted_y[i][1]), 2); } var index = 1 - ((6 * summation) / (n * (Math.pow(n, 2) - 1))); return index; }; -
frankbi created this gist
May 6, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ function getSpearmanRankCorrelation(list_x, list_y) { var n; if (list_x.length !== list_y.length) throw "Error: Lists are of different length"; else n = list_x.length; sorted_x = list_x.sort(); sorted_y = list_y.sort(); var summation = 0; for (var i = 0; i < n; i++) { summation += Math.pow((sorted_x[i][1] - sorted_y[i][1]), 2); } var rank = 1 - ((6 * summation) / (n * (Math.pow(n, 2) - 1))); return rank; };