JavaScript statistics libraries

Updated Nov 2026

JavaScript statistics libraries compute summaries such as the mean, variance, and quantiles, and work with probability distributions. Distribution functions return probabilities from a distribution or draw random samples from it. These libraries let dashboards, analytics tools, and AI agents describe data and run regressions in the browser or Node.js.

Popularity

d3-array has the most monthly downloads in this comparison, at 538.9M.

LibraryMonthly downloadsStarsLast releaseLicense
d3-array
552.6M
464Nov 2026ISC
d3-random
125.8M
139Nov 2026ISC
Math.js
21.3M
15.1KApr 2026Apache-2.0
ml-matrix
8.2M
403Oct 2026MIT
vega-statistics
7.7M
12.0KMar 2025BSD-3-Clause
jStat
6.0M
1.8KNov 2022MIT
Simple Statistics
5.3M
3.5KOct 2026ISC
@tensorflow/tfjs
2.4M
19.2KOct 2024Apache-2.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibrarySample SDNormal CDFNormal sampling
d3-arrayBuilt-inUnsupportedUnsupported
d3-randomUnsupportedUnsupportedBuilt-in
Math.jsBuilt-inUnsupportedUnsupported
ml-matrixBuilt-inUnsupportedUnsupported
vega-statisticsUnsupportedBuilt-inBuilt-in
jStatBuilt-inBuilt-inBuilt-in
Simple StatisticsBuilt-inBuilt-inUnsupported
@tensorflow/tfjsUnsupportedUnsupportedBuilt-in
Built-inNot supported

Libraries and code examples

Provides array summarization, ordering, grouping, and other data operations.

Downloads / mo
552.6M
Stars
464
Last release
3.2.5
License
ISC

Strengths

  • Skips missing values in means. Mean ignores null, undefined, and NaN values.
  • Summarizes records through accessors. Select a numeric field without manually constructing another input array.

Limitations

  • Variance needs multiple numeric values. Variance returns undefined when fewer than two numeric values remain.
  • quantileSorted needs sorted input. Sort the input first or use the regular quantile function.

Quickstart

From README.md
$ npm install d3-array
import { deviation } from 'd3-array';

console.log(deviation([1, 2, 3]));

d3-array examples

From open-source projects on GitHub

Generates random numbers from various distributions.

Downloads / mo
125.8M
Stars
139
Last release
3.0.2
License
ISC

Quickstart

From normal.js
$ npm install d3-random
import { randomNormal } from 'd3-random';

const draw = randomNormal(0, 1);
console.log(draw());

d3-random examples

From open-source projects on GitHub

Provides statistical functions within a broader mathematics library.

Downloads / mo
21.3M
Stars
15.1K
Last release
15.2.0
License
Apache-2.0

Strengths

  • Calculates across matrix dimensions. Compute variance over all values or along rows and columns.
  • Supports typed quantile inputs. Compute quantiles from Number, BigNumber, and Unit sequences.

Limitations

  • Mean flattens multidimensional inputs. Specify a dimension when the result should summarize rows or columns.
  • Variance uses sample normalization initially. Choose uncorrected normalization for population variance.

Quickstart

From variance.html
$ npm install mathjs
import { std } from 'mathjs';

console.log(std([1, 2, 3]));

Math.js examples

From open-source projects on GitHub

Manipulates and computes matrices.

Downloads / mo
8.2M
Stars
403
Last release
6.15.1
License
MIT

Quickstart

From README.md
$ npm install ml-matrix
import { Matrix } from 'ml-matrix';

const matrix = Matrix.ones(5, 5);

ml-matrix examples

From open-source projects on GitHub

vega-statistics

Provides statistical routines and probability distributions.

Downloads / mo
7.7M
Stars
12.0K
Last release
2.0.0
License
BSD-3-Clause

Quickstart

From bin.js
$ npm i vega-statistics
import { bin } from 'vega-statistics';

const bins = bin({ extent: [0, 10], maxbins: 5 });
console.log(bins);

vega-statistics examples

From open-source projects on GitHub

Provides statistical operations through static functions and wrapped numeric collections.

Downloads / mo
6.0M
Stars
1.8K
Last release
1.9.6
License
MIT

Strengths

  • Configures quantile estimation. Set the quantile parameters to match the required estimation method.
  • Offers static and wrapped APIs. Use static functions or chain operations on a jStat object.

Limitations

  • Variance defaults to the population. Pass true for sample variance when using the array API.
  • Matrix variance restricts sample selection. The matrix API cannot select population versus sample variance through its flag.

Quickstart

From overview.md
$ npm install --save jstat
const { jStat } = require('jstat');

console.log(jStat.mean([1, 2, 3]));

Simple Statistics

Provides descriptive, regression, and inference statistics.

Downloads / mo
5.3M
Stars
3.5K
Last release
8.0.0
License
ISC

Strengths

  • Separates sample and population variance. Choose variance for populations or sampleVariance for samples.
  • Computes sample correlations. Measure linear association between paired datasets with sampleCorrelation.

Limitations

  • Quantiles assume a complete population. Use its population quantile convention when comparing results across tools.

Quickstart

From README.md
$ npm install simple-statistics
import { min } from 'simple-statistics';

console.log(min([1, 2, 3]));

@tensorflow/tfjs

Provides an open-source machine learning framework.

Downloads / mo
2.4M
Stars
19.2K
Last release
4.22.0
License
Apache-2.0

Quickstart

From moments.ts
$ npm install @tensorflow/tfjs
import * as tf from '@tensorflow/tfjs';

await tf.ready();
const values = tf.tensor1d([1, 2, 3]);
const { mean, variance } = tf.moments(values);
mean.print();
variance.print();
tf.dispose([values, mean, variance]);

@tensorflow/tfjs examples

From open-source projects on GitHub

FAQ

Simple Statistics suits apps that need descriptive statistics, regression, and inference tests in one package. jStat suits code that needs named probability distributions alongside descriptive statistics. d3-array suits data pipelines that need summaries and quantiles.

Sample standard deviation divides by one less than the number of values to correct the bias of estimating from a sample. Population standard deviation divides by the full count. Math.js switches between the two with a setting.

jStat provides statistical routines for arrays and matrices along with named probability distribution functions. It computes values such as the normal CDF.

d3-random generates random numbers from the normal distribution and other distributions. jStat and Vega Statistics also sample from a normal distribution.

For coding agents

Found your statistics library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official