Maths functions
Project description
cjrh_math
A collection of handy maths functions.
Streaming mean and variance
Sometimes it can be very useful to update an existing mean and variance with new data, rather than have to calculate it again over the whole set. The functions below implement one of the algorithms described in Wikipedia.
def update_mean(n: int, mean: float, value: float) -> float
Given a new value, calculate a new mean using the existing mean and the size of data, n, seen so far.
def update_pvariance(n: int, mean: float, var: float, value: float) -> float
def update_variance(n: int, mean: float, var: float, value: float) -> float
Given a new value, calculate a new variance using the existing mean, existing variance var, and the size of data, n, seen so far.
Note that update_variance() is for sample variance while update_pvariance() is for population variance.
All functions are pure and therefore thread-safe.
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
File details
Details for the file cjrh_math-2017.11.1.tar.gz
.
File metadata
- Download URL: cjrh_math-2017.11.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60a3b9d1f4a42e937aa97d2d2a14f21db13822794aaf261a4ccb321574b4d3f1 |
|
MD5 | 5d6c9161a21da119cd933254a740d13f |
|
BLAKE2b-256 | 55e86d12983dd31a8b79982d1bf1ea5e660f524271dd33e3671962a8cd306764 |
File details
Details for the file cjrh_math-2017.11.1-py2.py3-none-any.whl
.
File metadata
- Download URL: cjrh_math-2017.11.1-py2.py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 690e585cf87c578c538ca0964b36010f336940cd324a2f46fe0841274744952d |
|
MD5 | 4ed4cf27fc09a1b44c2574be90ec96b6 |
|
BLAKE2b-256 | 950dbe5b26ae3a546838604bcb112ecd7f7e5013d9d3dfb3f5cdad970a4301c3 |