About stdlib...
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Statistical functions for arrays.
npm install @stdlib/stats-arrayAlternatively,
- To load the package in a website via a
scripttag without installation and bundlers, use the ES Module available on theesmbranch (see README). - If you are using Deno, visit the
denobranch (see README for usage intructions). - For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the
umdbranch (see README).
The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.
To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
var ns = require( '@stdlib/stats-array' );Namespace containing APIs for performing statistical operations on arrays.
var o = ns;
// returns {...}The namespace exports the following:
maxBy( x, clbk[, thisArg] ): calculate the maximum value of an array via a callback function.max( x ): calculate the maximum value of an array.maxabs( x ): calculate the maximum absolute value of an array.maxsorted( x ): calculate the maximum value of a sorted array.mean( x ): calculate the arithmetic mean of an array.meankbn( x ): calculate the arithmetic mean of an array using an improved Kahan–Babuška algorithm.meankbn2( x ): calculate the arithmetic mean of an array using a second-order iterative Kahan–Babuška algorithm.meanors( x ): calculate the arithmetic mean of an array using ordinary recursive summation.meanpn( x ): calculate the arithmetic mean of an array using a two-pass error correction algorithm.meanpw( x ): calculate the arithmetic mean of an array using pairwise summation.meanwd( x ): calculate the arithmetic mean of an array using Welford's algorithm.mediansorted( x ): calculate the median value of a sorted array.minBy( x, clbk[, thisArg] ): calculate the minimum value of an array via a callback function.min( x ): calculate the minimum value of an array.minabs( x ): calculate the minimum absolute value of an array.minsorted( x ): calculate the minimum value of a sorted array.mskmax( x, mask ): calculate the maximum value of an array according to a mask.mskmin( x, mask ): calculate the minimum value of an array according to a mask.mskrange( x, mask ): calculate the range of an array according to a mask.nanmaxBy( x, clbk[, thisArg] ): calculate the maximum value of an array via a callback function, ignoringNaNvalues.nanmax( x ): calculate the maximum value of an array, ignoringNaNvalues.nanmaxabs( x ): calculate the maximum absolute value of an array, ignoringNaNvalues.nanmean( x ): calculate the arithmetic mean of an array, ignoringNaNvalues.nanmeanors( x ): calculate the arithmetic mean of an array, ignoringNaNvalues and using ordinary recursive summation.nanmeanpn( x ): calculate the arithmetic mean of an array, ignoringNaNvalues and using a two-pass error correction algorithm.nanmeanwd( x ): calculate the arithmetic mean of an array, ignoringNaNvalues and using Welford's algorithm.nanminBy( x, clbk[, thisArg] ): calculate the minimum value of an array via a callback function, ignoringNaNvalues.nanmin( x ): calculate the minimum value of an array, ignoringNaNvalues.nanminabs( x ): calculate the minimum absolute value of an array, ignoringNaNvalues.nanmskmax( x, mask ): calculate the maximum value of an array according to a mask, ignoringNaNvalues.nanmskmin( x, mask ): calculate the minimum value of an array according to a mask, ignoringNaNvalues.nanmskrange( x, mask ): calculate the range of an array according to a mask, ignoringNaNvalues.nanrangeBy( x, clbk[, thisArg] ): calculate the range of an array via a callback function, ignoringNaNvalues.nanrange( x ): calculate the range of an array, ignoringNaNvalues.nanstdev( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues.nanstdevch( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues and using a one-pass trial mean algorithm.nanstdevpn( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues and using a two-pass algorithm.nanstdevtk( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues and using a one-pass textbook algorithm.nanstdevwd( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues and using Welford's algorithm.nanstdevyc( x[, correction] ): calculate the standard deviation of an array ignoringNaNvalues and using a one-pass algorithm proposed by Youngs and Cramer.nanvariance( x[, correction] ): calculate the variance of an array ignoringNaNvalues.nanvariancech( x[, correction] ): calculate the variance of an array ignoringNaNvalues and using a one-pass trial mean algorithm.nanvariancepn( x[, correction] ): calculate the variance of an array ignoringNaNvalues and using a two-pass algorithm.nanvariancetk( x[, correction] ): calculate the variance of an array ignoringNaNvalues and using a one-pass textbook algorithm.nanvariancewd( x[, correction] ): calculate the variance of an array ignoringNaNvalues and using Welford's algorithm.nanvarianceyc( x[, correction] ): calculate the variance of an array ignoringNaNvalues and using a one-pass algorithm proposed by Youngs and Cramer.rangeBy( x, clbk[, thisArg] ): calculate the range of an array via a callback function.range( x ): calculate the range of an array.stdev( x[, correction] ): calculate the standard deviation of an array.stdevch( x[, correction] ): calculate the standard deviation of an array using a one-pass trial mean algorithm.stdevpn( x[, correction] ): calculate the standard deviation of an array using a two-pass algorithm.stdevtk( x[, correction] ): calculate the standard deviation of an array using a one-pass textbook algorithm.stdevwd( x[, correction] ): calculate the standard deviation of an array using Welford's algorithm.stdevyc( x[, correction] ): calculate the standard deviation of an array using a one-pass algorithm proposed by Youngs and Cramer.variance( x[, correction] ): calculate the variance of an array.variancech( x[, correction] ): calculate the variance of an array using a one-pass trial mean algorithm.variancepn( x[, correction] ): calculate the variance of an array using a two-pass algorithm.variancetk( x[, correction] ): calculate the variance of an array using a one-pass textbook algorithm.variancewd( x[, correction] ): calculate the variance of an array using Welford's algorithm.varianceyc( x[, correction] ): calculate the variance of an array using a one-pass algorithm proposed by Youngs and Cramer.
var objectKeys = require( '@stdlib/utils-keys' );
var ns = require( '@stdlib/stats-array' );
console.log( objectKeys( ns ) );This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2026. The Stdlib Authors.