Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active December 15, 2017 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaleslimghost/d36ef95952a1b9fc24a2 to your computer and use it in GitHub Desktop.
Save apaleslimghost/d36ef95952a1b9fc24a2 to your computer and use it in GitHub Desktop.
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