Skip to main content

larzstats

Statistics without numpy/scipy. Pure Python, zero dependencies.

The everyday statistics you reach for on a list of numbers — central tendency and spread, quantiles, correlation, a least-squares fit you can predict from, and the normal distribution — all from math alone, working back to Python 3.8 (where the stdlib statistics module still lacks regression and correlation).

from larzstats import describe, linregress, correlation, normal_cdf

describe([2, 4, 4, 4, 5, 5, 7, 9])
# {'count': 8, 'mean': 5.0, 'std': 2.13.., 'min': 2, 'q1': 4.0,
#  'median': 4.5, 'q3': 5.5, 'max': 9}

fit = linregress([1, 2, 3, 4], [2.1, 3.9, 6.1, 8.0])
fit.slope, fit.r2, fit.predict(5)

correlation([1, 2, 3], [2, 4, 6])      # 1.0
normal_cdf(1.96)                       # 0.975

Why

  • The functions the stdlib doesn't give you (on 3.8). linregress (with slope/intercept/r/r2 and predict()), correlation, covariance, describe, iqr, z_score, normal_cdf/normal_pdf — no statistics version gate, no numpy.
  • Complete descriptives. mean/median/mode, geometric & harmonic means, sample and population variance/stdev, quantiles/percentiles/quartiles.
  • Zero dependencies. For scripts, dashboards, tests, and teaching — anywhere numpy is overkill. Pairs with larzchart to plot the results.

Install

pip install larzstats

Usage

from larzstats import (mean, median, mode, variance, stdev, quantile, percentile,
                       iqr, describe, correlation, linregress, normal_cdf, z_score)

mean(xs); median(xs); stdev(xs)            # sample by default; sample=False for population
quantile(xs, 0.9); percentile(xs, 90); iqr(xs)
describe(xs)                               # summary dict

fit = linregress(x, y); fit.predict(x0); fit.r2
correlation(x, y)                          # -1..1
normal_cdf(x, mu=0, sigma=1); z_score(x, mu, sigma)

Tests

python -m unittest discover -s tests -v   # 20 tests incl. regression + normal CDF

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.

License

MIT © larz-scripter

Metadata

Release files for larzstats 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for larzstats 0.1.0
File Size Uploaded Provenance
larzstats-0.1.0.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzstats 0.1.0
File Interpreter ABI Platform
larzstats-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / larzstats-0.1.0.tar.gz

Download URL larzstats-0.1.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c8e936a8c807e13f8841f1079362b21e47d335d33a344a93c46a6a3cdb2f0220
BLAKE2b-256 checksum
How to use checksums
1266f5437e87dfdbf87d0e3904cc80565d19e9d8ff2dd432b7300484a9c283b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzstats-0.1.0-py3-none-any.whl

Download URL larzstats-0.1.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbae10f0c95bcc44e0ced975a952cdf097e9b8d3c0c9425964d1d22a7118036b
BLAKE2b-256 checksum
How to use checksums
be5111043861b908dc9bda440dbc5d4dde520b5744488cebd3912730531fbf62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzstats 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.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page