@stdlib/stats-incr-grubbs

Grubbs' test for outliers.

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

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.3%) to scientific vocabulary

Keywords

deviate esd extreme grubbs hypothesis hypothesis-test javascript math mathematics maximum node node-js nodejs normalized residual statistics stats stdlib studentized test
Last synced: 4 months ago · JSON representation ·

Repository

Grubbs' test for outliers.

Basic Info
Statistics
  • Stars: 6
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
deviate esd extreme grubbs hypothesis hypothesis-test javascript math mathematics maximum node node-js nodejs normalized residual statistics stats stdlib studentized test
Created over 4 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

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!

incrgrubbs

NPM version Build Status Coverage Status <!-- dependencies -->

Grubbs' test for outliers.

[Grubbs' test][grubbs-test] (also known as the **maximum normalized residual test** or **extreme studentized deviate test**) is a statistical test used to detect outliers in a univariate dataset assumed to come from a normally distributed population. [Grubbs' test][grubbs-test] is defined for the hypothesis: - **H_0**: the dataset does **not** contain outliers. - **H_1**: the dataset contains **exactly** one outlier. The [Grubbs' test][grubbs-test] statistic for a two-sided alternative hypothesis is defined as ```math G = \frac{\max_{i=0,\ldots,N-1} |Y_i - \bar{Y}|}{s} ``` where `s` is the sample standard deviation. The [Grubbs test][grubbs-test] statistic is thus the largest absolute deviation from the sample mean in units of the sample standard deviation. The [Grubbs' test][grubbs-test] statistic for the alternative hypothesis that the minimum value is an outlier is defined as ```math G = \frac{\bar{Y} - Y_{\textrm{min}}}{s} ``` The [Grubbs' test][grubbs-test] statistic for the alternative hypothesis that the maximum value is an outlier is defined as ```math G = \frac{Y_{\textrm{max}} - \bar{Y}}{s} ``` For a two-sided test, the hypothesis that a dataset does **not** contain an outlier is rejected at significance level α if ```math G > \frac{N-1}{\sqrt{N}} \sqrt{\frac{t^2_{\alpha/(2N),N-2}}{N - 2 + t^2_{\alpha/(2N),N-2}}} ``` where `t` denotes the upper critical value of the _t_-distribution with `N-2` degrees of freedom and a significance level of `α/(2N)`. For a one-sided test, the hypothesis that a dataset does **not** contain an outlier is rejected at significance level α if ```math G > \frac{N-1}{\sqrt{N}} \sqrt{\frac{t^2_{\alpha/N,N-2}}{N - 2 + t^2_{\alpha/N,N-2}}} ``` where `t` denotes the upper critical value of the _t_-distribution with `N-2` degrees of freedom and a significance level of `α/N`.
## Installation ```bash npm install @stdlib/stats-incr-grubbs ``` 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 incrgrubbs = require( '@stdlib/stats-incr-grubbs' ); ``` #### incrgrubbs( \[options] ) Returns an accumulator `function` which incrementally performs [Grubbs' test][grubbs-test] for outliers. ```javascript var accumulator = incrgrubbs(); ``` The function accepts the following `options`: - **alpha**: significance level. Default: `0.05`. - **alternative**: alternative hypothesis. The option may be one of the following values: - `'two-sided'`: test whether the minimum or maximum value is an outlier. - `'min'`: test whether the minimum value is an outlier. - `'max'`: test whether the maximum value is an outlier. Default: `'two-sided'`. - **init**: number of data points the accumulator should use to compute initial statistics **before** testing for an outlier. Until the accumulator is provided the number of data points specified by this option, the accumulator returns `null`. Default: `100`. #### accumulator( \[x] ) If provided an input value `x`, the accumulator function returns updated test results. If not provided an input value `x`, the accumulator function returns the current test results. ```javascript var rnorm = require( '@stdlib/random-base-normal' ); var opts = { 'init': 0 }; var accumulator = incrgrubbs( opts ); var results = accumulator( rnorm( 10.0, 5.0 ) ); // returns null results = accumulator( rnorm( 10.0, 5.0 ) ); // returns null results = accumulator( rnorm( 10.0, 5.0 ) ); // returns results = accumulator(); // returns ``` The accumulator function returns an `object` having the following fields: - **rejected**: boolean indicating whether the null hypothesis should be rejected. - **alpha**: significance level. - **criticalValue**: critical value. - **statistic**: test statistic. - **df**: degrees of freedom. - **mean**: sample mean. - **sd**: corrected sample standard deviation. - **min**: minimum value. - **max**: maximum value. - **alt**: alternative hypothesis. - **method**: method name. - **print**: method for pretty-printing test output. The `print` method accepts the following options: - **digits**: number of digits after the decimal point. Default: `4`. - **decision**: `boolean` indicating whether to print the test decision. Default: `true`.
## Notes - [Grubbs' test][grubbs-test] **assumes** that data is normally distributed. Accordingly, one should first **verify** that the data can be _reasonably_ approximated by a normal distribution before applying the [Grubbs' test][grubbs-test]. - The accumulator must be provided **at least** three data points before performing [Grubbs' test][grubbs-test]. Until at least three data points are provided, the accumulator returns `null`. - Input values are **not** type checked. If provided `NaN` or a value which, when used in computations, results in `NaN`, the test statistic is `NaN` for **all** future invocations. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
## Examples ```javascript var incrgrubbs = require( '@stdlib/stats-incr-grubbs' ); var data; var opts; var acc; var i; // Define a data set (8 mass spectrometer measurements of a uranium isotope; see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; // Create a new accumulator: opts = { 'init': data.length, 'alternative': 'two-sided' }; acc = incrgrubbs( opts ); // Update the accumulator: for ( i = 0; i < data.length; i++ ) { acc( data[ i ] ); } // Print the test results: console.log( acc().print() ); /* e.g., => Grubbs' Test Alternative hypothesis: The maximum value (245.57) is an outlier criticalValue: 2.1266 statistic: 2.4688 df: 6 Test Decision: Reject null in favor of alternative at 5% significance level */ ```
* * * ## References - Grubbs, Frank E. 1950. "Sample Criteria for Testing Outlying Observations." _The Annals of Mathematical Statistics_ 21 (1). The Institute of Mathematical Statistics: 27–58. doi:[10.1214/aoms/1177729885][@grubbs:1950a]. - Grubbs, Frank E. 1969. "Procedures for Detecting Outlying Observations in Samples." _Technometrics_ 11 (1). Taylor & Francis: 1–21. doi:[10.1080/00401706.1969.10490657][@grubbs:1969a].
* * * ## 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].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 32
Last Year
  • Push event: 32

Committers

Last synced: almost 2 years ago

All Time
  • Total Commits: 42
  • Total Committers: 1
  • Avg Commits per committer: 42.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 11
  • Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 42
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 206 last-month
  • Total dependent packages: 6
  • Total dependent repositories: 6
  • Total versions: 10
  • Total maintainers: 4
npmjs.org: @stdlib/stats-incr-grubbs

Grubbs' test for outliers.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.2.2
    published over 1 year ago
  • Versions: 10
  • Dependent Packages: 6
  • Dependent Repositories: 6
  • Downloads: 206 Last month
Rankings
Dependent packages count: 3.2%
Dependent repos count: 4.6%
Average: 9.0%
Downloads: 10.8%
Stargazers count: 10.9%
Forks count: 15.4%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 5 months ago

Dependencies

.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
package.json npm
  • @stdlib/assert-is-function ^0.0.x development
  • @stdlib/bench ^0.0.x development
  • @stdlib/datasets-herndon-venus-semidiameters ^0.0.x development
  • @stdlib/random-base-normal ^0.0.x development
  • @stdlib/stats-incr-max ^0.0.x development
  • @stdlib/stats-incr-mean ^0.0.x development
  • @stdlib/stats-incr-min ^0.0.x development
  • @stdlib/stats-incr-stdev ^0.0.x development
  • istanbul ^0.4.1 development
  • tap-min 2.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/assert-has-own-property ^0.0.x
  • @stdlib/assert-is-boolean ^0.0.x
  • @stdlib/assert-is-nan ^0.0.x
  • @stdlib/assert-is-nonnegative-integer ^0.0.x
  • @stdlib/assert-is-number ^0.0.x
  • @stdlib/assert-is-plain-object ^0.0.x
  • @stdlib/assert-is-positive-integer ^0.0.x
  • @stdlib/assert-is-string ^0.0.x
  • @stdlib/math-base-special-max ^0.0.x
  • @stdlib/math-base-special-roundn ^0.0.x
  • @stdlib/math-base-special-sqrt ^0.0.x
  • @stdlib/stats-base-dists-t-quantile ^0.0.x
  • @stdlib/stats-incr-meanstdev ^0.0.x
  • @stdlib/stats-incr-minmax ^0.0.x
  • @stdlib/string-format ^0.0.x
  • @stdlib/utils-copy ^0.0.x
  • @stdlib/utils-define-read-only-accessor ^0.0.x
  • @stdlib/utils-define-read-only-property ^0.0.x