A light statistical package that operates on numeric Arrays.
A fairly light statistical package. Works with numeric arrays, and will automatically filter out non-numeric values and attempt to convert string numeric values.
var stats =var dice =var rolls =for var i = 0; i < 3000; i++rollsconsoleconsoleconsoleconsoleconsoleconsoleconsole/* Your exact numbers may vary, but they should be pretty similar:sum: 21006mean: 7.002median: 7mode: 7variance: 5.907329333333325standard deviation: 2.43049981142425285th percentile: 10*/
Compatibility Notice: Version 2.0.0+ of this library use features that require Node.js v4.0.0 and above
All of the exported functions take
vals which is an array of numeric values. Non-numeric values will be removed, and string numbers will be converted to Numbers.
NOTE: This will impact some operations, e.g.
mean([null, 1, 2, 3]) will be calculated as
mean([1, 2, 3]), (e.g.
6 / 3 = 2, NOT
6 / 4 = 1.5)
Accepts an array of values and returns an array consisting of only numeric values from the source array. Converts what it can and filters out anything else. e.g.
// [1, 22.9, 9]
Sum the values in the array.
Calculate the mean average value of
Calculate the median average value of
Calculate the mode average value of
vals is multi-modal (contains multiple modes),
mode(vals) will return a ES6 Set of the modes.
Calculate the variance from the mean.
Calculate the standard deviation of the values from the mean.
Calculate the value representing the desired percentile
(0 < ptile <= 1). Uses the Estimation method to interpolate non-member percentiles.