Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stdlib-js/stats

Standard library statistical functions.
https://github.com/stdlib-js/stats

javascript lib library math mathematics node node-js nodejs standard statistics stats stdlib

Last synced: about 9 hours ago
JSON representation

Standard library statistical functions.

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!

# Stats

[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url]

> Statistical functions.

## Installation

```bash
npm install @stdlib/stats
```

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 statistics = require( '@stdlib/stats' );
```

#### statistics

Namespace containing statistical functions.

```javascript
var stats = statistics;
// returns {...}
```

The namespace exposes the following statistical tests:

- [`anova1( x, factor[, opts] )`][@stdlib/stats/anova1]: perform a one-way analysis of variance.
- [`bartlettTest( a[,b,...,k][, opts] )`][@stdlib/stats/bartlett-test]: compute Bartlett’s test for equal variances.
- [`binomialTest( x[, n][, opts] )`][@stdlib/stats/binomial-test]: exact test for the success probability in a Bernoulli experiment.
- [`chi2gof( x, y[, ...args][, options] )`][@stdlib/stats/chi2gof]: perform a chi-square goodness-of-fit test.
- [`chi2test( x[, options] )`][@stdlib/stats/chi2test]: perform a chi-square independence test.
- [`flignerTest( a[,b,...,k][, opts] )`][@stdlib/stats/fligner-test]: compute the Fligner-Killeen test for equal variances.
- [`kruskalTest( a[,b,...,k][, opts] )`][@stdlib/stats/kruskal-test]: compute the Kruskal-Wallis test for equal medians.
- [`kstest( x, y[, ...params][, opts] )`][@stdlib/stats/kstest]: one-sample Kolmogorov-Smirnov goodness-of-fit test.
- [`leveneTest( x[, y, ..., z][, opts] )`][@stdlib/stats/levene-test]: compute Levene's test for equal variances.
- [`pcorrtest( x, y[, opts] )`][@stdlib/stats/pcorrtest]: compute a Pearson product-moment correlation test between paired samples.
- [`ttest( x[, y][, opts] )`][@stdlib/stats/ttest]: one-sample and paired Student's t-Test.
- [`ttest2( x, y[, opts] )`][@stdlib/stats/ttest2]: two-sample Student's t-Test.
- [`vartest( x, y[, opts] )`][@stdlib/stats/vartest]: two-sample F-test for equal variances.
- [`wilcoxon( x[, y][, opts] )`][@stdlib/stats/wilcoxon]: one-sample and paired Wilcoxon signed rank test.
- [`ztest( x, sigma[, opts] )`][@stdlib/stats/ztest]: one-sample z-Test.
- [`ztest2( x, y, sigmax, sigmay[, opts] )`][@stdlib/stats/ztest2]: two-sample z-Test.

In addition, it contains an assortment of functions for computing statistics incrementally as part of the `incr` sub-namespace and functions for computing statistics over iterators in the `iterators` namespace.

- [`incr`][@stdlib/stats/incr]: incremental statistics.
- [`iterators`][@stdlib/stats/iter]: statistical function iterators.

The `base` sub-namespace contains functions to calculate statistics alongside a `dists` namespace containing functions related to a wide assortment of probability distributions.

- [`base`][@stdlib/stats/base]: base (i.e., lower-level) statistical functions.

Other statistical functions included are:

- [`kde2d()`][@stdlib/stats/kde2d]: two-dimensional kernel density estimation.
- [`lowess( x, y[, opts] )`][@stdlib/stats/lowess]: locally-weighted polynomial regression via the LOWESS algorithm.
- [`padjust( pvals, method[, comparisons] )`][@stdlib/stats/padjust]: adjust supplied p-values for multiple comparisons.
- [`ranks( arr[, opts] )`][@stdlib/stats/ranks]: compute ranks for values of an array-like object.

## Examples

```javascript
var objectKeys = require( '@stdlib/utils/keys' );
var statistics = require( '@stdlib/stats' );

console.log( objectKeys( statistics ) );
```

* * *

## 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-2025. The Stdlib [Authors][stdlib-authors].

[npm-image]: http://img.shields.io/npm/v/@stdlib/stats.svg
[npm-url]: https://npmjs.org/package/@stdlib/stats

[test-image]: https://github.com/stdlib-js/stats/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/stats/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/stats?branch=main

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im

[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/tree/deno
[deno-readme]: https://github.com/stdlib-js/stats/blob/deno/README.md
[umd-url]: https://github.com/stdlib-js/stats/tree/umd
[umd-readme]: https://github.com/stdlib-js/stats/blob/umd/README.md
[esm-url]: https://github.com/stdlib-js/stats/tree/esm
[esm-readme]: https://github.com/stdlib-js/stats/blob/esm/README.md
[branches-url]: https://github.com/stdlib-js/stats/blob/main/branches.md

[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats/main/LICENSE

[@stdlib/stats/kde2d]: https://github.com/stdlib-js/stats/tree/main/kde2d

[@stdlib/stats/lowess]: https://github.com/stdlib-js/stats/tree/main/lowess

[@stdlib/stats/padjust]: https://github.com/stdlib-js/stats/tree/main/padjust

[@stdlib/stats/ranks]: https://github.com/stdlib-js/stats/tree/main/ranks

[@stdlib/stats/base]: https://github.com/stdlib-js/stats/tree/main/base

[@stdlib/stats/incr]: https://github.com/stdlib-js/stats/tree/main/incr

[@stdlib/stats/iter]: https://github.com/stdlib-js/stats/tree/main/iter

[@stdlib/stats/anova1]: https://github.com/stdlib-js/stats/tree/main/anova1

[@stdlib/stats/bartlett-test]: https://github.com/stdlib-js/stats/tree/main/bartlett-test

[@stdlib/stats/binomial-test]: https://github.com/stdlib-js/stats/tree/main/binomial-test

[@stdlib/stats/chi2gof]: https://github.com/stdlib-js/stats/tree/main/chi2gof

[@stdlib/stats/chi2test]: https://github.com/stdlib-js/stats/tree/main/chi2test

[@stdlib/stats/fligner-test]: https://github.com/stdlib-js/stats/tree/main/fligner-test

[@stdlib/stats/kruskal-test]: https://github.com/stdlib-js/stats/tree/main/kruskal-test

[@stdlib/stats/kstest]: https://github.com/stdlib-js/stats/tree/main/kstest

[@stdlib/stats/levene-test]: https://github.com/stdlib-js/stats/tree/main/levene-test

[@stdlib/stats/pcorrtest]: https://github.com/stdlib-js/stats/tree/main/pcorrtest

[@stdlib/stats/ttest]: https://github.com/stdlib-js/stats/tree/main/ttest

[@stdlib/stats/ttest2]: https://github.com/stdlib-js/stats/tree/main/ttest2

[@stdlib/stats/vartest]: https://github.com/stdlib-js/stats/tree/main/vartest

[@stdlib/stats/wilcoxon]: https://github.com/stdlib-js/stats/tree/main/wilcoxon

[@stdlib/stats/ztest]: https://github.com/stdlib-js/stats/tree/main/ztest

[@stdlib/stats/ztest2]: https://github.com/stdlib-js/stats/tree/main/ztest2