star-linefit 0.1.0
Least-squares line and correlation, correctly rounded
Public state: Released & Verified. The registry label is RELEASED. What the states mean →
Apache-2.0 Released & Verified single file
Summary
Least-squares straight line, standard errors of slope and intercept, residual standard deviation and Pearson correlation computed exactly in rational arithmetic and rounded once; on 500 datasets all six results are identical to the exact rational value from SymPy; reproduces the five certified values of the NIST Norris dataset to 1e-13 relative.
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 28 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_linefit-0.1.0-py3-none-any.whl 3 kB
- Single file — copy it alongside your code · star_linefit.py 4 kB
- Source code (.zip) 22 kB
python -m pip install star_linefit-0.1.0-py3-none-any.whlIn Python: import star_linefit
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_linefit_0_1_0,
author = {Cavazzini, Andrea},
title = {{star-linefit}: Least-squares line and correlation, correctly rounded},
version = {0.1.0},
year = {2026},
url = {https://andrea07072000.github.io/S.T.A.R.-/software/star_linefit/},
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-linefit @ git+https://github.com/Andrea07072000/S.T.A.R.-.git@dc09f61dcee098d518f070d6a23a8815defc1109#subdirectory=packages/star_linefit"
Technical sheet
Requirements
- R1
fit(xs, ys)returns (slope, intercept) of the line that minimises the sum of squared vertical residuals;fit_errorsreturns the standard errors of the two and the residual standard deviation (n - 2 degrees of freedom);correlationreturns Pearson's r. - R2 Every result is the float nearest to the exact value of its formula applied to the numbers given, square roots included; it does not depend on the order of the points, and r is exactly ±1 only for points exactly on a line.
- R3 Measured on 500 datasets of 3 to 40 points: all six results identical to the exact rational value (SymPy) rounded once. SciPy, NumPy and CPython's
statisticsagree within 1e-7 of the natural scale on the half of the corpus with x within ±10; on the half with x near 1e6 to 1e9 their own rounding reaches 4e-7. The NIST reference dataset Norris is reproduced to 1e-13 relative on its five certified values. - R4 Every function returns floats or raises
ValueError: data that are not lists or tuples of 2 to 100000 finite numbers within 1e100, different lengths, all x equal, all y equal (correlation), fewer than 3 points (errors), a result too large for a float.
Limits (what is not claimed)
An ordinary least-squares line with errors only in y, equal weights and no intercept constraint: no weighted fit, no errors in x, no polynomial or robust fit, no confidence intervals or tests. The standard errors assume independent residuals of equal variance, which this module cannot check. "Exact" refers to the floats supplied. Exact arithmetic is slower than floating point: it is for results that must not depend on rounding, not for large arrays.
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_linefit.py 0.907 (2026-10-07)
- Independent implementations written by others (needs 2)
- CPython statistics, numpy.polyfit and corrcoef, scipy.stats.linregress
- Also compared with, not counted
- S.T.A.R.'s own re-derivations: SymPy exact rationals
- Result
- Released & Verified
Evidence in the registry
| Check | Status | Recorded | What was observed |
|---|---|---|---|
| Unit tests | VERIFIED | 2026-10-07 | 28 passed in 0.44s |
| 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 | 1.0021168180204545, -0.26232307377402675, 0.0004297968481999412, 0.2328182343011548, 0.8847963961443813 (suite: 28 passed in 0.44s) |
| Cross-check with independent libraries | VERIFIED | 2026-10-07 | star_linefit returns the least-squares line, its standard errors and the correlation as the exact value of each formula rounded once |
| Benchmark | VERIFIED | 2026-10-07 | results not identical to the exact value: 0; NIST Norris certified values reproduced to 1e-13 relative: True |
| Clean install from the release tag | VERIFIED | 2026-10-07 | pytest outside the tree: 28 passed in 0.27s |
Fingerprints (SHA-256)
| star_linefit-0.1.0-py3-none-any.whl | 6adff0bbf33fd37deab84d1e12269eb9f410da6c016b45d3e58e729ce972a130 |
| star_linefit.py | 74f3ffaddda01a38aec122396ea21385fdba4e451abb7a51e9a27d7df6da6533 |
| star_linefit-0.1.0-source.zip | 1413190e95a0b61fe03eb413a030dcad291eafb3761738f6172f877f36754d86 |
