Created
June 4, 2012 20:10
-
-
Save aedoran/2870581 to your computer and use it in GitHub Desktop.
normally distribute data nd split them into 0-100 buckets
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
var data = [2,3,4,5,3,2,3,4,5,6,9,9,100,-100]; | |
var avg = 0; | |
data.forEach(function(a) { | |
avg+= a; | |
}); | |
avg = avg / data.length; | |
console.log("avg",avg); | |
var devs = 0; | |
data.forEach(function(a) { | |
devs += Math.pow(avg-a,2); | |
}); | |
var standard_deviation = Math.sqrt(devs/(data.length-1)); | |
console.log("std",standard_deviation); | |
//now put them into buckets of 0-100j | |
data.forEach(function(a) { | |
console.log(a,(100/2)+(100/8)*(a-avg)/standard_deviation); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment