Library for computing linear statistics.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe5769809c5c8d91bcdece528b846608500eccebb71dde18d9a6bbd63eefd3d7
|
|
| MD5 |
5dcf309133084b6e282fe507c0cf83bb
|
|
| BLAKE2b-256 |
23946596d19522759c030b31e550650affa8f193adc4c1617e7c77235a73a6ac
|
Provenance
The following attestation bundles were made for running_stats-0.2.0.tar.gz:
Publisher:
release.yml on spraakbanken/running-stats-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
running_stats-0.2.0.tar.gz -
Subject digest:
fe5769809c5c8d91bcdece528b846608500eccebb71dde18d9a6bbd63eefd3d7 - Sigstore transparency entry: 740095337
- Sigstore integration time:
-
Permalink:
spraakbanken/running-stats-py@324427d8f83947e6c2c7f32d46be87d1af0b361e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/spraakbanken
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@324427d8f83947e6c2c7f32d46be87d1af0b361e -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8afe39c2827fcb1d5be382525994a37d3af47fd69f15743adb10a60d79db16f
|
|
| MD5 |
dc0be45f18213df39b4601db43a95e96
|
|
| BLAKE2b-256 |
272e0eb4795643f48eb3af33f9e936fe1cad7890c86ab01b30f10798c255d08d
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
running_stats-0.2.0-py3-none-any.whl -
Subject digest:
d8afe39c2827fcb1d5be382525994a37d3af47fd69f15743adb10a60d79db16f - Sigstore transparency entry: 740095348
- Sigstore integration time:
-
Permalink:
spraakbanken/running-stats-py@324427d8f83947e6c2c7f32d46be87d1af0b361e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/spraakbanken
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@324427d8f83947e6c2c7f32d46be87d1af0b361e -
Trigger Event:
push
-
Statement type: