Here are some of the kinds of things you can do:
// Find the mean (average) of a set of numbers. This // takes an array of numbers var mean = ss.mean([1, 2, 3]); // The variance of numbers is the sum of the squared // differences between numbers and the mean of the list. var variance = ss.variance([1, 2, 3]); // Create a linear regression based on a dataset of // two-dimensional arrays. This returns a new function // that you can call for the value of the line at // each X value. var linear_regression_line = ss.linear_regression() .data([[0, 1], [2, 2], [3, 3]]).line(); linear_regression_line(5); // The r-squared function can be given a dataset just // like linear regressions, and it'll tell you roughly how // close the linear regression comes to actually estimating // the data. var r_squared = ss.r_squared([[1, 2]], linear_regression_line);
Libraries like science.js, R, and descriptive-statistics are written by smarter people and are probably more performant and shiny. The point of
simple-statistics is that it’s simple, accessible, and aims to be as low on concept as possible.
simple-statistics with npm or download
simple_statistics.js from GitHub to use it in the browser.