Skip to content

Instantly share code, notes, and snippets.

@buboh
buboh / statistics.js
Created March 22, 2019 10:31
Mean, standard deviation, quartiles, median JavaScript implementation
// sort array ascending
const asc = arr => arr.sort((a, b) => a - b);
const sum = arr => arr.reduce((a, b) => a + b, 0);
const mean = arr => sum(arr) / arr.length;
// sample standard deviation
const std = (arr) => {
const mu = mean(arr);

Keybase proof

I hereby claim:

  • I am buboh on github.
  • I am buboh (https://keybase.io/buboh) on keybase.
  • I have a public key ASDG4oKtwB1kHPzKnfQ1SO0GjKS6a1shIsU2U75Flv7srQo

To claim this, I am signing this object: