descriptive-statistics-kit
v2.0.1
Published
Summary statistics for numeric arrays: mean, variance, stddev, median, quantiles, skewness, kurtosis, covariance and Pearson correlation.
Maintainers
Readme
descriptive-statistics
Summary statistics for plain arrays of numbers. No dependencies, ESM only.
Everything is a plain function that takes a number[] and returns a number (or an
object for summary). Variance-based functions default to the sample estimator
(Bessel's correction, n - 1); pass false as the last argument to switch to the
population estimator.
Install
npm install descriptive-statisticsUsage
import { mean, stddev, median, quantile, correlation } from "descriptive-statistics";
mean([1, 2, 3, 4, 5]); // 3
stddev([2, 4, 4, 4, 5, 5, 7, 9], false); // 2 (population)
median([1, 2, 3, 4]); // 2.5
quantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.25); // 3.25
correlation([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1API
Single series:
mean(xs)variance(xs, sample = true)stddev(xs, sample = true)min(xs),max(xs),range(xs)median(xs)quantile(xs, q)— linear-interpolation (type 7) quantile forqin[0, 1]iqr(xs)— interquartile rangeskewness(xs)— bias-adjusted Fisher-Pearson skewness (needs ≥ 3 points)kurtosis(xs)— bias-corrected excess kurtosis (needs ≥ 4 points; normal ≈ 0)summary(xs)—{ n, mean, stddev, min, max, median }
Two series:
covariance(xs, ys, sample = true)correlation(xs, ys)— Pearson r in[-1, 1]
License
BSD-3-Clause
