Tiny statistics helper lib for node and the browser. Robust and fast.
npm install math-helpers
(or just download math-helpers.js if you want to use it in the browser)
Node (or with browserify)
var math = require('math-helpers')(/* options */)
var avg = math.avg([1, 2, 3])
// TODO: document the other methods
Browser:
AMD (with a script load like require.js)
define(['path/to/math-helpers'], function (mh) {
var math = mh(/* options */)
// use it...
})
Old and busted script tag (seriously, you shouldn't to that anymore :-P)
<script src="fancy://cdn.com/math-helpers.js"></script>
<script>
var math = window.MathHelpers(/* options */)
</script>
You can pass some options to the module.
{
precision: 3 // results will be rounded to this number of decimals
}