https://github.com/stdlib-js/stats-array
Statistical functions for arrays.
https://github.com/stdlib-js/stats-array
array javascript namespace node node-js nodejs statistics stats stdlib vector
Last synced: 2 months ago
JSON representation
Statistical functions for arrays.
- Host: GitHub
- URL: https://github.com/stdlib-js/stats-array
- Owner: stdlib-js
- License: apache-2.0
- Created: 2025-06-01T10:04:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-06T03:45:48.000Z (3 months ago)
- Last Synced: 2026-04-06T05:26:53.106Z (3 months ago)
- Topics: array, javascript, namespace, node, node-js, nodejs, statistics, stats, stdlib, vector
- Language: JavaScript
- Homepage: https://github.com/stdlib-js/stdlib
- Size: 1.07 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Security: SECURITY.md
- Notice: NOTICE
Awesome Lists containing this project
README
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!
# Statistics
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url]
> Statistical functions for arrays.
## Installation
```bash
npm install @stdlib/stats-array
```
Alternatively,
- To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]).
- If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions).
- For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]).
The [branches.md][branches-url] 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.
## Usage
```javascript
var ns = require( '@stdlib/stats-array' );
```
#### ns
Namespace containing APIs for performing statistical operations on arrays.
```javascript
var o = ns;
// returns {...}
```
The namespace exports the following:
- [`maxBy( x, clbk[, thisArg] )`][@stdlib/stats/array/max-by]: calculate the maximum value of an array via a callback function.
- [`max( x )`][@stdlib/stats/array/max]: calculate the maximum value of an array.
- [`maxabs( x )`][@stdlib/stats/array/maxabs]: calculate the maximum absolute value of an array.
- [`maxsorted( x )`][@stdlib/stats/array/maxsorted]: calculate the maximum value of a sorted array.
- [`mean( x )`][@stdlib/stats/array/mean]: calculate the arithmetic mean of an array.
- [`meankbn( x )`][@stdlib/stats/array/meankbn]: calculate the arithmetic mean of an array using an improved Kahan–Babuška algorithm.
- [`meankbn2( x )`][@stdlib/stats/array/meankbn2]: calculate the arithmetic mean of an array using a second-order iterative Kahan–Babuška algorithm.
- [`meanors( x )`][@stdlib/stats/array/meanors]: calculate the arithmetic mean of an array using ordinary recursive summation.
- [`meanpn( x )`][@stdlib/stats/array/meanpn]: calculate the arithmetic mean of an array using a two-pass error correction algorithm.
- [`meanpw( x )`][@stdlib/stats/array/meanpw]: calculate the arithmetic mean of an array using pairwise summation.
- [`meanwd( x )`][@stdlib/stats/array/meanwd]: calculate the arithmetic mean of an array using Welford's algorithm.
- [`mediansorted( x )`][@stdlib/stats/array/mediansorted]: calculate the median value of a sorted array.
- [`minBy( x, clbk[, thisArg] )`][@stdlib/stats/array/min-by]: calculate the minimum value of an array via a callback function.
- [`min( x )`][@stdlib/stats/array/min]: calculate the minimum value of an array.
- [`minabs( x )`][@stdlib/stats/array/minabs]: calculate the minimum absolute value of an array.
- [`minsorted( x )`][@stdlib/stats/array/minsorted]: calculate the minimum value of a sorted array.
- [`mskmax( x, mask )`][@stdlib/stats/array/mskmax]: calculate the maximum value of an array according to a mask.
- [`mskmin( x, mask )`][@stdlib/stats/array/mskmin]: calculate the minimum value of an array according to a mask.
- [`mskrange( x, mask )`][@stdlib/stats/array/mskrange]: calculate the range of an array according to a mask.
- [`nanmaxBy( x, clbk[, thisArg] )`][@stdlib/stats/array/nanmax-by]: calculate the maximum value of an array via a callback function, ignoring `NaN` values.
- [`nanmax( x )`][@stdlib/stats/array/nanmax]: calculate the maximum value of an array, ignoring `NaN` values.
- [`nanmaxabs( x )`][@stdlib/stats/array/nanmaxabs]: calculate the maximum absolute value of an array, ignoring `NaN` values.
- [`nanmean( x )`][@stdlib/stats/array/nanmean]: calculate the arithmetic mean of an array, ignoring `NaN` values.
- [`nanmeanors( x )`][@stdlib/stats/array/nanmeanors]: calculate the arithmetic mean of an array, ignoring `NaN` values and using ordinary recursive summation.
- [`nanmeanpn( x )`][@stdlib/stats/array/nanmeanpn]: calculate the arithmetic mean of an array, ignoring `NaN` values and using a two-pass error correction algorithm.
- [`nanmeanwd( x )`][@stdlib/stats/array/nanmeanwd]: calculate the arithmetic mean of an array, ignoring `NaN` values and using Welford's algorithm.
- [`nanminBy( x, clbk[, thisArg] )`][@stdlib/stats/array/nanmin-by]: calculate the minimum value of an array via a callback function, ignoring `NaN` values.
- [`nanmin( x )`][@stdlib/stats/array/nanmin]: calculate the minimum value of an array, ignoring `NaN` values.
- [`nanminabs( x )`][@stdlib/stats/array/nanminabs]: calculate the minimum absolute value of an array, ignoring `NaN` values.
- [`nanmskmax( x, mask )`][@stdlib/stats/array/nanmskmax]: calculate the maximum value of an array according to a mask, ignoring `NaN` values.
- [`nanmskmin( x, mask )`][@stdlib/stats/array/nanmskmin]: calculate the minimum value of an array according to a mask, ignoring `NaN` values.
- [`nanmskrange( x, mask )`][@stdlib/stats/array/nanmskrange]: calculate the range of an array according to a mask, ignoring `NaN` values.
- [`nanrangeBy( x, clbk[, thisArg] )`][@stdlib/stats/array/nanrange-by]: calculate the range of an array via a callback function, ignoring `NaN` values.
- [`nanrange( x )`][@stdlib/stats/array/nanrange]: calculate the range of an array, ignoring `NaN` values.
- [`nanstdev( x[, correction] )`][@stdlib/stats/array/nanstdev]: calculate the standard deviation of an array ignoring `NaN` values.
- [`nanstdevch( x[, correction] )`][@stdlib/stats/array/nanstdevch]: calculate the standard deviation of an array ignoring `NaN` values and using a one-pass trial mean algorithm.
- [`nanstdevpn( x[, correction] )`][@stdlib/stats/array/nanstdevpn]: calculate the standard deviation of an array ignoring `NaN` values and using a two-pass algorithm.
- [`nanstdevtk( x[, correction] )`][@stdlib/stats/array/nanstdevtk]: calculate the standard deviation of an array ignoring `NaN` values and using a one-pass textbook algorithm.
- [`nanstdevwd( x[, correction] )`][@stdlib/stats/array/nanstdevwd]: calculate the standard deviation of an array ignoring `NaN` values and using Welford's algorithm.
- [`nanstdevyc( x[, correction] )`][@stdlib/stats/array/nanstdevyc]: calculate the standard deviation of an array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
- [`nanvariance( x[, correction] )`][@stdlib/stats/array/nanvariance]: calculate the variance of an array ignoring `NaN` values.
- [`nanvariancech( x[, correction] )`][@stdlib/stats/array/nanvariancech]: calculate the variance of an array ignoring `NaN` values and using a one-pass trial mean algorithm.
- [`nanvariancepn( x[, correction] )`][@stdlib/stats/array/nanvariancepn]: calculate the variance of an array ignoring `NaN` values and using a two-pass algorithm.
- [`nanvariancetk( x[, correction] )`][@stdlib/stats/array/nanvariancetk]: calculate the variance of an array ignoring `NaN` values and using a one-pass textbook algorithm.
- [`nanvariancewd( x[, correction] )`][@stdlib/stats/array/nanvariancewd]: calculate the variance of an array ignoring `NaN` values and using Welford's algorithm.
- [`nanvarianceyc( x[, correction] )`][@stdlib/stats/array/nanvarianceyc]: calculate the variance of an array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
- [`rangeBy( x, clbk[, thisArg] )`][@stdlib/stats/array/range-by]: calculate the range of an array via a callback function.
- [`range( x )`][@stdlib/stats/array/range]: calculate the range of an array.
- [`stdev( x[, correction] )`][@stdlib/stats/array/stdev]: calculate the standard deviation of an array.
- [`stdevch( x[, correction] )`][@stdlib/stats/array/stdevch]: calculate the standard deviation of an array using a one-pass trial mean algorithm.
- [`stdevpn( x[, correction] )`][@stdlib/stats/array/stdevpn]: calculate the standard deviation of an array using a two-pass algorithm.
- [`stdevtk( x[, correction] )`][@stdlib/stats/array/stdevtk]: calculate the standard deviation of an array using a one-pass textbook algorithm.
- [`stdevwd( x[, correction] )`][@stdlib/stats/array/stdevwd]: calculate the standard deviation of an array using Welford's algorithm.
- [`stdevyc( x[, correction] )`][@stdlib/stats/array/stdevyc]: calculate the standard deviation of an array using a one-pass algorithm proposed by Youngs and Cramer.
- [`variance( x[, correction] )`][@stdlib/stats/array/variance]: calculate the variance of an array.
- [`variancech( x[, correction] )`][@stdlib/stats/array/variancech]: calculate the variance of an array using a one-pass trial mean algorithm.
- [`variancepn( x[, correction] )`][@stdlib/stats/array/variancepn]: calculate the variance of an array using a two-pass algorithm.
- [`variancetk( x[, correction] )`][@stdlib/stats/array/variancetk]: calculate the variance of an array using a one-pass textbook algorithm.
- [`variancewd( x[, correction] )`][@stdlib/stats/array/variancewd]: calculate the variance of an array using Welford's algorithm.
- [`varianceyc( x[, correction] )`][@stdlib/stats/array/varianceyc]: calculate the variance of an array using a one-pass algorithm proposed by Youngs and Cramer.
## Examples
```javascript
var objectKeys = require( '@stdlib/utils-keys' );
var ns = require( '@stdlib/stats-array' );
console.log( objectKeys( ns ) );
```
* * *
## Notice
This package is part of [stdlib][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][stdlib], see the main project [repository][stdlib].
#### Community
[![Chat][chat-image]][chat-url]
---
## License
See [LICENSE][stdlib-license].
## Copyright
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-array.svg
[npm-url]: https://npmjs.org/package/@stdlib/stats-array
[test-image]: https://github.com/stdlib-js/stats-array/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/stats-array/actions/workflows/test.yml?query=branch:main
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-array/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/stats-array?branch=main
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
[chat-url]: https://stdlib.zulipchat.com
[stdlib]: https://github.com/stdlib-js/stdlib
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
[umd]: https://github.com/umdjs/umd
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
[deno-url]: https://github.com/stdlib-js/stats-array/tree/deno
[deno-readme]: https://github.com/stdlib-js/stats-array/blob/deno/README.md
[umd-url]: https://github.com/stdlib-js/stats-array/tree/umd
[umd-readme]: https://github.com/stdlib-js/stats-array/blob/umd/README.md
[esm-url]: https://github.com/stdlib-js/stats-array/tree/esm
[esm-readme]: https://github.com/stdlib-js/stats-array/blob/esm/README.md
[branches-url]: https://github.com/stdlib-js/stats-array/blob/main/branches.md
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-array/main/LICENSE
[@stdlib/stats/array/max-by]: https://github.com/stdlib-js/stats-array-max-by
[@stdlib/stats/array/max]: https://github.com/stdlib-js/stats-array-max
[@stdlib/stats/array/maxabs]: https://github.com/stdlib-js/stats-array-maxabs
[@stdlib/stats/array/maxsorted]: https://github.com/stdlib-js/stats-array-maxsorted
[@stdlib/stats/array/mean]: https://github.com/stdlib-js/stats-array-mean
[@stdlib/stats/array/meankbn]: https://github.com/stdlib-js/stats-array-meankbn
[@stdlib/stats/array/meankbn2]: https://github.com/stdlib-js/stats-array-meankbn2
[@stdlib/stats/array/meanors]: https://github.com/stdlib-js/stats-array-meanors
[@stdlib/stats/array/meanpn]: https://github.com/stdlib-js/stats-array-meanpn
[@stdlib/stats/array/meanpw]: https://github.com/stdlib-js/stats-array-meanpw
[@stdlib/stats/array/meanwd]: https://github.com/stdlib-js/stats-array-meanwd
[@stdlib/stats/array/mediansorted]: https://github.com/stdlib-js/stats-array-mediansorted
[@stdlib/stats/array/min-by]: https://github.com/stdlib-js/stats-array-min-by
[@stdlib/stats/array/min]: https://github.com/stdlib-js/stats-array-min
[@stdlib/stats/array/minabs]: https://github.com/stdlib-js/stats-array-minabs
[@stdlib/stats/array/minsorted]: https://github.com/stdlib-js/stats-array-minsorted
[@stdlib/stats/array/mskmax]: https://github.com/stdlib-js/stats-array-mskmax
[@stdlib/stats/array/mskmin]: https://github.com/stdlib-js/stats-array-mskmin
[@stdlib/stats/array/mskrange]: https://github.com/stdlib-js/stats-array-mskrange
[@stdlib/stats/array/nanmax-by]: https://github.com/stdlib-js/stats-array-nanmax-by
[@stdlib/stats/array/nanmax]: https://github.com/stdlib-js/stats-array-nanmax
[@stdlib/stats/array/nanmaxabs]: https://github.com/stdlib-js/stats-array-nanmaxabs
[@stdlib/stats/array/nanmean]: https://github.com/stdlib-js/stats-array-nanmean
[@stdlib/stats/array/nanmeanors]: https://github.com/stdlib-js/stats-array-nanmeanors
[@stdlib/stats/array/nanmeanpn]: https://github.com/stdlib-js/stats-array-nanmeanpn
[@stdlib/stats/array/nanmeanwd]: https://github.com/stdlib-js/stats-array-nanmeanwd
[@stdlib/stats/array/nanmin-by]: https://github.com/stdlib-js/stats-array-nanmin-by
[@stdlib/stats/array/nanmin]: https://github.com/stdlib-js/stats-array-nanmin
[@stdlib/stats/array/nanminabs]: https://github.com/stdlib-js/stats-array-nanminabs
[@stdlib/stats/array/nanmskmax]: https://github.com/stdlib-js/stats-array-nanmskmax
[@stdlib/stats/array/nanmskmin]: https://github.com/stdlib-js/stats-array-nanmskmin
[@stdlib/stats/array/nanmskrange]: https://github.com/stdlib-js/stats-array-nanmskrange
[@stdlib/stats/array/nanrange-by]: https://github.com/stdlib-js/stats-array-nanrange-by
[@stdlib/stats/array/nanrange]: https://github.com/stdlib-js/stats-array-nanrange
[@stdlib/stats/array/nanstdev]: https://github.com/stdlib-js/stats-array-nanstdev
[@stdlib/stats/array/nanstdevch]: https://github.com/stdlib-js/stats-array-nanstdevch
[@stdlib/stats/array/nanstdevpn]: https://github.com/stdlib-js/stats-array-nanstdevpn
[@stdlib/stats/array/nanstdevtk]: https://github.com/stdlib-js/stats-array-nanstdevtk
[@stdlib/stats/array/nanstdevwd]: https://github.com/stdlib-js/stats-array-nanstdevwd
[@stdlib/stats/array/nanstdevyc]: https://github.com/stdlib-js/stats-array-nanstdevyc
[@stdlib/stats/array/nanvariance]: https://github.com/stdlib-js/stats-array-nanvariance
[@stdlib/stats/array/nanvariancech]: https://github.com/stdlib-js/stats-array-nanvariancech
[@stdlib/stats/array/nanvariancepn]: https://github.com/stdlib-js/stats-array-nanvariancepn
[@stdlib/stats/array/nanvariancetk]: https://github.com/stdlib-js/stats-array-nanvariancetk
[@stdlib/stats/array/nanvariancewd]: https://github.com/stdlib-js/stats-array-nanvariancewd
[@stdlib/stats/array/nanvarianceyc]: https://github.com/stdlib-js/stats-array-nanvarianceyc
[@stdlib/stats/array/range-by]: https://github.com/stdlib-js/stats-array-range-by
[@stdlib/stats/array/range]: https://github.com/stdlib-js/stats-array-range
[@stdlib/stats/array/stdev]: https://github.com/stdlib-js/stats-array-stdev
[@stdlib/stats/array/stdevch]: https://github.com/stdlib-js/stats-array-stdevch
[@stdlib/stats/array/stdevpn]: https://github.com/stdlib-js/stats-array-stdevpn
[@stdlib/stats/array/stdevtk]: https://github.com/stdlib-js/stats-array-stdevtk
[@stdlib/stats/array/stdevwd]: https://github.com/stdlib-js/stats-array-stdevwd
[@stdlib/stats/array/stdevyc]: https://github.com/stdlib-js/stats-array-stdevyc
[@stdlib/stats/array/variance]: https://github.com/stdlib-js/stats-array-variance
[@stdlib/stats/array/variancech]: https://github.com/stdlib-js/stats-array-variancech
[@stdlib/stats/array/variancepn]: https://github.com/stdlib-js/stats-array-variancepn
[@stdlib/stats/array/variancetk]: https://github.com/stdlib-js/stats-array-variancetk
[@stdlib/stats/array/variancewd]: https://github.com/stdlib-js/stats-array-variancewd
[@stdlib/stats/array/varianceyc]: https://github.com/stdlib-js/stats-array-varianceyc