Skip to main content

Library for computing linear statistics.

Project description

running-stats

PyPI version PyPI license PyPI - Python Version

Maturity badge - level 2 Stage

Code Coverage Maintainability

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.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

Project details


Download files

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

Source Distribution

running_stats-0.2.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

running_stats-0.2.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file running_stats-0.2.0.tar.gz.

File metadata

  • Download URL: running_stats-0.2.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for running_stats-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fe5769809c5c8d91bcdece528b846608500eccebb71dde18d9a6bbd63eefd3d7
MD5 5dcf309133084b6e282fe507c0cf83bb
BLAKE2b-256 23946596d19522759c030b31e550650affa8f193adc4c1617e7c77235a73a6ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for running_stats-0.2.0.tar.gz:

Publisher: release.yml on spraakbanken/running-stats-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file running_stats-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: running_stats-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for running_stats-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8afe39c2827fcb1d5be382525994a37d3af47fd69f15743adb10a60d79db16f
MD5 dc0be45f18213df39b4601db43a95e96
BLAKE2b-256 272e0eb4795643f48eb3af33f9e936fe1cad7890c86ab01b30f10798c255d08d

See more details on using hashes here.

Provenance

The following attestation bundles were made for running_stats-0.2.0-py3-none-any.whl:

Publisher: release.yml on spraakbanken/running-stats-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page