star-stats 0.1.0
Summary statistics, correctly rounded
Public state: Released & Verified. The registry label is RELEASED. What the states mean →
Apache-2.0 Released & Verified single file
Summary
Mean, sample and population variance and standard deviation, root mean square and weighted mean computed exactly in rational arithmetic and rounded once, independent of the order of the values; on 500 datasets all seven statistics are identical to mpmath at 400 digits rounded once and to CPython's statistics module where it has them; reproduces the NIST NumAcc1 and NumAcc2 reference datasets.
Run in your browser
Edit the code and press Run (or Ctrl+Enter). Python runs in your browser with this package's published code. The first run downloads Python once (about 12 MB).
Runs in the browser: all 43 tests pass in the browser's Python (Pyodide 314.0.7, Python 3.14.2), measured on 20 October 2026. Open it in the Workspace →
Use it on your computer
No account and no GitHub needed. Download, then install with one command:
- Install file · star_stats-0.1.0-py3-none-any.whl 3 kB
- Single file — copy it alongside your code · star_stats.py 4 kB
- Source code (.zip) 21 kB
python -m pip install star_stats-0.1.0-py3-none-any.whlIn Python: import star_stats
Cite it, and its bill of materials
For a paper, a report or a supplier file: the citation in two formats, and the software bill of materials (SBOM) in the two standard formats, with the fingerprint of the wheel.
@software{cavazzini_star_stats_0_1_0,
author = {Cavazzini, Andrea},
title = {{star-stats}: Summary statistics, correctly rounded},
version = {0.1.0},
year = {2026},
url = {https://andrea07072000.github.io/S.T.A.R.-/software/star_stats/},
note = {Apache-2.0. Source: https://github.com/Andrea07072000/S.T.A.R.-, commit dc09f61d}
}
For developers
Install directly from the public repository:
python -m pip install "star-stats @ git+https://github.com/Andrea07072000/S.T.A.R.-.git@dc09f61dcee098d518f070d6a23a8815defc1109#subdirectory=packages/star_stats"
Technical sheet
Requirements
- R1
mean,variance,stdev,rmsandweighted_meanreturn the float nearest to the exact value of their formula applied to the numbers given (a float is an exact fraction). The result does not depend on the order of the values. - R2
varianceandstdevare the sample statistics (divisor n - 1) by default and the population statistics withsample=False. Square roots are rounded correctly from the exact fraction, with no underflow or overflow of the squares. - R3 Measured on 500 datasets of 2 to 60 values (mixed magnitudes, large offsets, equal values, integers): all seven statistics are identical to mpmath at 400 digits rounded once, and to CPython's
statisticsmodule where it has them; NumPy and SciPy differ by at most 5e-16 of the natural scale, which is their own rounding. - R4 Every function returns a float or raises
ValueError: data that are not a list or tuple of 1 to 100000 finite numbers within 1e150 (booleans refused), a sample statistic of a single value, asamplethat is not a bool, weights that are negative, all zero, not finite or of another length.
Limits (what is not claimed)
"Exact" refers to the floats supplied: 0.1 is not one tenth, and the statistics of measurements carry the error of the measurements, which no arithmetic removes. On Python 3.12 the standard statistics module returns the same mean, variance and standard deviation: this package adds the root mean square, the exact weighted mean, the stated limits and refusals, and the independent check. Exact arithmetic is slower than floating point (about one second for 100000 values): it is for results that must not depend on rounding, not for large arrays. No medians, quantiles, covariance, regression or uncertainty of the estimates.
Release gate
Computed by the registry from the result files, with the same function that decides RELEASED.
- Mutation score, latest measure of each module (needs at least 0.850)
- star_stats.py 0.914 (2026-10-07)
- Independent implementations written by others (needs 2)
- CPython statistics module, numpy, scipy.stats
- Also compared with, not counted
- S.T.A.R.'s own re-derivations: mpmath at 400 digits
- Result
- Released & Verified
Evidence in the registry
| Check | Status | Recorded | What was observed |
|---|---|---|---|
| Clean install from the release tag | VERIFIED | 2026-10-07 | pytest outside the tree: 43 passed in 0.54s |
| Unit tests | VERIFIED | 2026-10-07 | 43 passed in 0.76s |
| Review | VERIFIED | 2026-10-07 | Requirements, interface, units, data provenance, dependency surface and failure behaviour reviewed |
| Review | VERIFIED | 2026-10-07 | Re-running the cross-check gives a byte-identical evidence file |
| Reference value | VERIFIED | 2026-10-07 | mean = 1.2 and stdev = 0.09999999999999998 (the exact statistic of the floats 1.1, 1.2, 1.3); mean = 10000002.0 and stdev = 1.0 (suite: 43 passed in 0.76s) |
| Cross-check with independent libraries | VERIFIED | 2026-10-07 | star_stats returns the mean, variance, standard deviation, RMS and weighted mean as the exact value of the formula rounded once to a float |
| Benchmark | VERIFIED | 2026-10-07 | results not identical to the 400-digit value: 0 of 3500 |
Fingerprints (SHA-256)
| star_stats-0.1.0-py3-none-any.whl | d8c137e4b86d8a853989765e6081acbc90ac9ce42ed890d85fec532b465c3260 |
| star_stats.py | cbad713fea7ac0eccf083983e327a045b06c966b1867b4eb91730b00172176e6 |
| star_stats-0.1.0-source.zip | 26841d1beebde37cb87767dfc8d4dd6e2a155cad57e30bc4f00ca36d326fa26b |
