Last active
December 15, 2017 11:09
-
-
Save apaleslimghost/d36ef95952a1b9fc24a2 to your computer and use it in GitHub Desktop.
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 sum = require('lodash.sum'); | |
module.exports = function gaussian(ns) { | |
var n = ns.length; | |
var mean = sum(ns) / n; | |
var d = ns.map(a => Math.pow(mean - a, 2)); | |
var stdev = Math.sqrt(sum(d) / n); | |
var max = Math.max.apply(Math, ns); | |
var min = Math.min.apply(Math, ns); | |
return {mean, stdev, n, max, min}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment