running-stats
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.gitgit clone https://github.com/spraakbanken/running-stats-py.git
- Setup environment:
make dev - Install
pre-commithooks:pre-commit install
Do your work.
Tasks to do:
- Test the code with
make testormake 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.mdto your liking. - Add to git:
git add --update - Commit with
git commit -m 'chore(release): prepare release'orcog 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=patchormake bumpversion
- Major:
- Push
mainand tags to GitHub:git push main --tagsormake publish- GitHub Actions workflow will build, test and publish the package to PyPi.
Metadata
Release files for running-stats 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| running_stats-0.2.0.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| running_stats-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.3 kB
Release files / running_stats-0.2.0.tar.gz
| Download URL | running_stats-0.2.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe5769809c5c8d91bcdece528b846608500eccebb71dde18d9a6bbd63eefd3d7
|
|
BLAKE2b-256 checksum How to use checksums |
23946596d19522759c030b31e550650affa8f193adc4c1617e7c77235a73a6ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 4, 2025.
Transparency logRelease files / running_stats-0.2.0-py3-none-any.whl
| Download URL | running_stats-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8afe39c2827fcb1d5be382525994a37d3af47fd69f15743adb10a60d79db16f
|
|
BLAKE2b-256 checksum How to use checksums |
272e0eb4795643f48eb3af33f9e936fe1cad7890c86ab01b30f10798c255d08d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Dec 4, 2025.
Transparency log