robustmodels
Robust location, scale and covariance estimators for Python. Early development: the API may change before version 1.0.
Install
pip install robustmodels
Requires Python 3.10+, NumPy, SciPy and scikit-learn.
Use
from robustmodels import location, scale
x = [1, 2, 2, 3, 4, 100]
location.hodges_lehmann(x)
scale.mad(x)
scale.qn(x)
Covariance estimators follow the scikit-learn interface:
import numpy as np
from robustmodels.covariance import MCD
X = np.random.default_rng(0).normal(size=(100, 3))
X[:10] += 8
model = MCD(random_state=0).fit(X)
model.location_
model.covariance_
model.mahalanobis(X) # squared distances
model.support_ # observations kept after reweighting
Estimators
| Module | Contents |
|---|---|
robustmodels.location |
hodges_lehmann, m_location, tau_location, trimmed_mean, winsorized_mean |
robustmodels.scale |
mad, qn, sn, pn, tau_scale, m_scale; skewness and tail weight: medcouple, lmc, rmc |
robustmodels.covariance |
MCD, MRCD, MVE, OGK, SEstimator, MMEstimator; correction factors: h_alpha_n, mcd_consistency, mcd_small_sample |
The documentation explains how
to choose and use each estimator and documents every function and class. The same
information is in the docstrings: help(robustmodels.scale.qn).
Univariate functions accept finite, one-dimensional samples. Empty samples return
NaN. A single observation has zero scale. Covariance estimators accept matrices
with observations in rows. MRCD supports more variables than observations and
uses an identity regularization target. MVE requires alpha < 1.
MRCD needs an explicit positive rho when a starting subset has zero scatter.
Qn, Sn and Pn include finite-sample corrections by default. Pass
finite_correction=False to disable them. Pn uses the factors from
Tarr (2014), Appendix B.3.
Development
uv sync --locked
uv run pytest
uv run ruff check .
uv run ruff format --check .
Build and check the distributions:
uv build
uvx twine check --strict dist/*
Run the docstring examples and build the documentation:
uv run pytest --doctest-modules --pyargs robustmodels
uv run --group docs sphinx-build -W -b html docs docs/_build/html
CI runs the tests against the installed wheel on Python 3.10 to 3.14. The Python 3.10 job uses the minimum supported NumPy, SciPy and scikit-learn versions.
The examples in docs/ and in the docstrings run as tests. The tests cover estimator definitions, statistical properties, edge cases,
agreement with R's robustbase and rrcov, and
scikit-learn compatibility.
Code lives in src/robustmodels:
| File | Contents | Internal dependencies |
|---|---|---|
location.py |
Location estimators | scale.py, _validation.py |
scale.py |
Scale, skewness, correction factors and pairwise selection | _validation.py |
covariance.py |
Covariance estimators and their fitting steps | scale.py, _validation.py |
_validation.py |
Input and parameter checks | None |
Each method and its steps stay together. Auditing an estimator requires its file
and at most two supporting files. __init__.py exposes the three public modules.
Release
- Set
versioninpyproject.toml, runuv lock, and replace "unreleased" in CHANGELOG.md with the date. - Merge into
main, then tag and push:git tag v0.1.0 && git push origin v0.1.0. - CI tests, builds and, after approval of the
pypienvironment, publishes to PyPI through trusted publishing. The tag must match the package version.
License
BSD 3-Clause; see LICENSE.
Metadata
Release files for robustmodels 0.1.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 |
|---|---|---|---|---|
| robustmodels-0.1.0.tar.gz | 43.0 kB | With provenance | Details for robustmodels-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robustmodels-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for robustmodels-0.1.0-py3-none-any.whl |
Total release size: 69.5 kB
Release files / robustmodels-0.1.0.tar.gz
| Download URL | robustmodels-0.1.0.tar.gz |
|---|---|
| Size | 43.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91919685d7434fb2e782ae56d74445a69a97cb32fd0872382b0a65d414da8127
|
|
BLAKE2b-256 checksum How to use checksums |
71792a8e5de40a370c60796d747a91415e24feb20e96c9bcb6d20adf4e824158
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / robustmodels-0.1.0-py3-none-any.whl
| Download URL | robustmodels-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d419de80001894dcc060dd9bc62c53359ec2dd4965348e9ecf27bdd7c45018e7
|
|
BLAKE2b-256 checksum How to use checksums |
f001ea4b171cacd1e793932727a9debf76488a27a4db922832ee93be16a22840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logSecurity for robustmodels 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for robustmodels-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logA 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.