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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larzstats-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzstats-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file larzstats-0.1.0.tar.gz.

File metadata

  • Download URL: larzstats-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzstats-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8e936a8c807e13f8841f1079362b21e47d335d33a344a93c46a6a3cdb2f0220
MD5 7315007940fe6c5f4accc12b2ae886c4
BLAKE2b-256 1266f5437e87dfdbf87d0e3904cc80565d19e9d8ff2dd432b7300484a9c283b0

See more details on using hashes here.

File details

Details for the file larzstats-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzstats-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzstats-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbae10f0c95bcc44e0ced975a952cdf097e9b8d3c0c9425964d1d22a7118036b
MD5 7fad6bac931b985cc37cbfc03c8340a5
BLAKE2b-256 be5111043861b908dc9bda440dbc5d4dde520b5744488cebd3912730531fbf62

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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