robustats
Robust statistics for NumPy — replaces
meanwithmedianfor outlier-resistant data analysis.
Why?
NumPy's np.mean is sensitive to outliers. One extreme value can distort your entire analysis. robustats swaps mean with median by default — a far more robust estimator — while keeping the same familiar API.
data = [1, 2, 3, 4, 1000]
np.mean(data) # 202.0 ← distorted by outlier
rs.mean(data) # 3.0 ← robust, ignores outlier
Installation
pip install robustats
Quick Start
import numpy as np
import robustats as rs
data = [1, 2, 3, 4, 1000]
# Drop-in replacements
rs.mean(data) # 3.0 (median, robust)
rs.nanmean(data) # 3.0 (nanmedian, robust)
rs.std(data) # 1.4826 (MAD-based, robust)
rs.var(data) # 2.198 (MAD², robust)
rs.mad(data) # 1.4826 (Median Absolute Deviation)
# Use arithmetic mean explicitly
rs.mean(data, use_median=False) # 202.0
# Weighted median
rs.average(data, weights=[1,1,1,1,10]) # 5.0
Context Manager — patch np.mean temporarily
with rs.robust_mode():
np.mean(data) # 3.0 inside the block
np.mean(data) # 202.0 restored after the block
Global Patch — replace np.mean everywhere
rs.patch_numpy()
np.mean(data) # 3.0 (global replacement)
rs.unpatch_numpy()
np.mean(data) # 202.0 (restored)
API Reference
| Function | Description |
|---|---|
rs.mean(a, axis, use_median=True) |
Median (or mean) of array |
rs.nanmean(a, axis, use_median=True) |
Nanmedian (or nanmean) |
rs.std(a, axis, use_mad=True) |
MAD-based std (or numpy std) |
rs.var(a, axis, use_mad=True) |
MAD²-based var (or numpy var) |
rs.mad(a, axis, scale=1.4826) |
Median Absolute Deviation |
rs.average(a, weights, use_median=True) |
Weighted median (or average) |
rs.robust_mode() |
Context manager patching np.mean |
rs.patch_numpy() |
Globally replace np.mean / np.nanmean |
rs.unpatch_numpy() |
Restore originals |
When to use robustats
- Your data may have outliers or measurement errors
- You're doing exploratory data analysis on real-world datasets
- You need a quick drop-in without changing all your
np.meancalls (robust_modecontext) - You want robust standard deviation via MAD instead of classical std
License
MIT
Metadata
Release files for robustats-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| robustats_py-0.2.0.tar.gz | 10.2 kB | Without provenance | Details for robustats_py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robustats_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for robustats_py-0.2.0-py3-none-any.whl |
Total release size: 19.5 kB
Release files / robustats_py-0.2.0.tar.gz
| Download URL | robustats_py-0.2.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28826f3242db875d95ae71c980e5887a4b36dac9b33ada81ea61411f470da535
|
|
BLAKE2b-256 checksum How to use checksums |
257baa393e2c5be1e9572c85022bc1603a57e37bd93be2d05221b5cd863ce7dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / robustats_py-0.2.0-py3-none-any.whl
| Download URL | robustats_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c14ae24e0dd08e30ed33c4751d46b734b2d82b393e49ddeaafc26b0faa1778f
|
|
BLAKE2b-256 checksum How to use checksums |
dad4eb642c92384f151af7bd5a2dd02dcc0ed3eff3f41022fd16c78c26255e2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for robustats-py 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.