Fast Grubbs' test implementation with C++ bindings.
Project description
Stat Grubb
High speed Grubbs Test used to calculate the the z-score data points in a data set. I created this to learn about c++ and python integration and to have an fast alternate to the major python libaries. You can view the package on pypi here.
How the Algorithm Works
run_Grubbs — Grubbs Test with Outlier Removal
This is an iterative algorithm that progressively removes outliers from the dataset before computing z-scores.
run_NoOutlier — Standard Z-Score (No Outlier Removal)
A single-pass calculation with no iterative removal:
- Compute mean and standard deviation across the entire dataset.
- Compute
z = (x − mean) / sdfor every data point.
Because no points are removed, outliers pull the mean and standard deviation toward themselves, which compresses z-scores across the rest of the dataset.
Implementation Specifics
- The dataset is assumed to follow a normal distribution.
- The Grubbs test is designed for detecting one outlier per iteration; the loop repeats to handle multiple outliers.
- Mean and standard deviation are computed with Welford's algorithm to avoid floating-point cancellation errors.
Performance
Benchmarked against an equivalent pure-Python/NumPy/SciPy implementation:
| Dataset | run_Grubbs speedup |
run_NoOutlier speedup |
|---|---|---|
| 1k | 43× | 1.3× |
| 10k | 8× | 1.2× |
| 100k | 2.5× | 1.3× |
The large gains in run_Grubbs come from O(1) outlier removal (swap-to-end) and incremental mean/variance updates (reverse Welford), avoiding repeated full-array passes.
Installing GrubbsTest
macOS only (Apple Silicon)
pip install grubbstest
Usage
import fastgrubbstest as g
Functions
run_Grubbs(data, alpha=0.05)- Calculates z-scores with iterative outlier removal from mean and standard deviation calculation
- Outliers still receive a z-score, computed relative to the cleaned distribution
run_NoOutlier(data)- Calculates z-scores without removing outliers from mean and standard deviation
Inputs
-
run_Grubbsdata: data in dict formatalpha: significance level for Student's t-distribution (default0.05)
-
run_NoOutlierdata: data in dict format
Input Format
- A dictionary where each key is the ID and the value is the number
{"ab": 85, "cd": 4, ...}
Output Format
- A dictionary where each key is the ID and the value is a list of
[original_value, z_score]{"ab": [85, 1.23], "cd": [4, -0.56], ...}
License
This project is licensed under the MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grubbstest-2.0.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: grubbstest-2.0.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 81.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
278514736c429fe3b7b72e69a54e00a962962e3dec9d382ca28819425282aebe
|
|
| MD5 |
cefdcdb54ae5d7ee410e5dc0e0de01c2
|
|
| BLAKE2b-256 |
df07e76f0659774159efa1643fc30e707b979f5fdbdd698c2c4c276e3879ffd8
|
Provenance
The following attestation bundles were made for grubbstest-2.0.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish.yml on davidolejniczak/FastGrubbsTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grubbstest-2.0.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
278514736c429fe3b7b72e69a54e00a962962e3dec9d382ca28819425282aebe - Sigstore transparency entry: 1228183330
- Sigstore integration time:
-
Permalink:
davidolejniczak/FastGrubbsTest@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/davidolejniczak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file grubbstest-2.0.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: grubbstest-2.0.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 81.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42acd3c6d8ee9deb5cb947214811aa3ae3373c5979c131e4582f97cb8609e939
|
|
| MD5 |
a6e16424c1945c05f6d2f458be479168
|
|
| BLAKE2b-256 |
97e731416c01d4cebd3100fa89e4de6e0c1bbdee02b48a694d9b582aa823c40c
|
Provenance
The following attestation bundles were made for grubbstest-2.0.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
publish.yml on davidolejniczak/FastGrubbsTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grubbstest-2.0.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
42acd3c6d8ee9deb5cb947214811aa3ae3373c5979c131e4582f97cb8609e939 - Sigstore transparency entry: 1228183281
- Sigstore integration time:
-
Permalink:
davidolejniczak/FastGrubbsTest@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/davidolejniczak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file grubbstest-2.0.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: grubbstest-2.0.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 82.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
533fc99d1acbc9cfa575d18f553be876e44041fe1ffde8578712eeec0b44b84d
|
|
| MD5 |
c3173115863d6815900fb2e7ee395f35
|
|
| BLAKE2b-256 |
6a1633f1373638488d6785f913fcacb11b5e298e58b86f56469b9f3ef5d1ef04
|
Provenance
The following attestation bundles were made for grubbstest-2.0.0-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
publish.yml on davidolejniczak/FastGrubbsTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grubbstest-2.0.0-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
533fc99d1acbc9cfa575d18f553be876e44041fe1ffde8578712eeec0b44b84d - Sigstore transparency entry: 1228183301
- Sigstore integration time:
-
Permalink:
davidolejniczak/FastGrubbsTest@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/davidolejniczak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file grubbstest-2.0.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: grubbstest-2.0.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 82.3 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32d622e2e1ed4f2f1eacd5d1c19f8a2bee10882893e59c3bb0f00e3fad4b826f
|
|
| MD5 |
020862e216802e5f66fef6ec8e775104
|
|
| BLAKE2b-256 |
e0d3a099ed1579525cf801dfa7ffdd89caf3c40e610fb3f1ebfd05dce2ec694a
|
Provenance
The following attestation bundles were made for grubbstest-2.0.0-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
publish.yml on davidolejniczak/FastGrubbsTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grubbstest-2.0.0-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
32d622e2e1ed4f2f1eacd5d1c19f8a2bee10882893e59c3bb0f00e3fad4b826f - Sigstore transparency entry: 1228183312
- Sigstore integration time:
-
Permalink:
davidolejniczak/FastGrubbsTest@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/davidolejniczak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Trigger Event:
push
-
Statement type:
File details
Details for the file grubbstest-2.0.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: grubbstest-2.0.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 82.3 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55f135b9f8575a3e9129d8f51c3fa6e704fa8071875cf38beb8152871af6db3c
|
|
| MD5 |
6745efad46903b62891ac5127050b4a3
|
|
| BLAKE2b-256 |
a9df9bb513425d55b7990abb5f9ca8ea6aaa2ede9479714e79cbea18f7b41335
|
Provenance
The following attestation bundles were made for grubbstest-2.0.0-cp39-cp39-macosx_11_0_arm64.whl:
Publisher:
publish.yml on davidolejniczak/FastGrubbsTest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grubbstest-2.0.0-cp39-cp39-macosx_11_0_arm64.whl -
Subject digest:
55f135b9f8575a3e9129d8f51c3fa6e704fa8071875cf38beb8152871af6db3c - Sigstore transparency entry: 1228183294
- Sigstore integration time:
-
Permalink:
davidolejniczak/FastGrubbsTest@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/davidolejniczak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8cb61bc2d7c4ae0cdefd58bd379ed374e5cb8d4c -
Trigger Event:
push
-
Statement type: