Skip to main content

running-stats

PyPI version PyPI license PyPI - Python Version

Maturity badge - level 2 Stage

Code Coverage

CI(check) CI(release) CI(rolling) CI(test)

Inspired by John D. Cook's blog

Add to your project

uv

To add running-stats to your project:

uv add running-stats

Usage

To compute running mean and variance, use RunningMeanVar. Numerical stable.

mean_var = RunningMeanVar()

for value in floats_from_somewhere():
    mean_var.push(value)
    # you can read values during iteration
    # print(mean_var.mean())
    # print(mean_var.variance())

# Let's print mean and variance of all values
print(mean_var.mean())
print(mean_var.variance())

You can also combine two RunningMeanVar:s.

mean_var1 = RunningMeanVar()

for value in floats_from_somewhere1():
    mean_var1.push(value)

mean_var2 = RunningMeanVar()

for value in floats_from_somewhere2():
    mean_var2.push(value)

combined = mean_var1 + mean_var2

# Let's print mean and variance of all values
print(combined.mean())
print(combined.variance())

Minimum Supported Python Version Policy

The Minimum Supported Python Version is fixed for a given minor (1.x) version. However it can be increased when bumping minor versions, i.e. going from 1.0 to 1.1 allows us to increase the Minimum Supported Python Version. Users unable to increase their Python version can use an older minor version instead. Below is a list of running-stats versions and their Minimum Supported Python Version:

  • v0.3: Python 3.11.
  • v0.2: Python 3.10.
  • v0.1: Python 3.9.

Note however that running-stats also has dependencies, which might have different MSPV policies. We try to stick to the above policy when updating dependencies, but this is not always possible.

Changelog

This project keeps a changelog.

License

This repository is licensed under the MIT license.

Development

Development prerequisites

For starting to develop on this repository:

  • Clone the repo (in one of the ways below):
    • git clone git@github.com:spraakbanken/running-stats-py.git
    • git clone https://github.com/spraakbanken/running-stats-py.git
  • Setup environment: make dev
  • Install pre-commit hooks: pre-commit install

Do your work.

Tasks to do:

  • Test the code with make test or make test-w-coverage.
  • Lint the code with make lint.
  • Check formatting with make check-fmt.
  • Format the code with make fmt.
  • Type-check the code with make type-check.

This repo uses conventional commits.

Release a new version

  • Prepare the CHANGELOG: make prepare-release.
  • Edit CHANGELOG.md to your liking.
  • Add to git: git add --update
  • Commit with git commit -m 'chore(release): prepare release' or cog commit chore 'prepare release' release.
  • Bump version (depends on `bump-my-version)
    • Major: make bumpversion part=major
    • Minor: make bumpversion part=minor
    • Patch: make bumpversion part=patch or make bumpversion
  • Push main and tags to GitHub: git push main --tags or make publish

Metadata

Release files for running-stats 0.3.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 running-stats 0.3.0
File Size Uploaded Provenance Actions
running_stats-0.3.0.tar.gz 4.5 kB With provenance Details for running_stats-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for running-stats 0.3.0
File Interpreter ABI Platform Actions
running_stats-0.3.0-py3-none-any.whl Python 3 none any Details for running_stats-0.3.0-py3-none-any.whl

Total release size: 10.0 kB

Release files / running_stats-0.3.0.tar.gz

Download URL running_stats-0.3.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
24bec6e55cfcc3f1afc0aa76aa2ab88a6b3f2a3705a77c1bdfb15f486ba75e8e
BLAKE2b-256 checksum
How to use checksums
2603d753672935f54cc4956fdbb5c3e245cf78e8a401eee1ef61037ee21abb01
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 24, 2026.

Transparency log

Release files / running_stats-0.3.0-py3-none-any.whl

Download URL running_stats-0.3.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21504050e9e1166c8cf791441787d0c7e34102a4a780ec364f16aa4e1d7236a9
BLAKE2b-256 checksum
How to use checksums
7cb73890b94bf279b1b293a26868e2c8df75b64c2d247c762a870a182432fe99
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 24, 2026.

Transparency log

Security for running-stats 0.3.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.

Select from 2 files

Attestation for running_stats-0.3.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 24, 2026.

Transparency log

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.

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