Skip to main content
https://travis-ci.org/cjrh/cjrh_math.svg?branch=master https://coveralls.io/repos/github/cjrh/cjrh_math/badge.svg?branch=master https://img.shields.io/pypi/pyversions/cjrh_math.svg https://img.shields.io/github/tag/cjrh/cjrh_math.svg https://img.shields.io/badge/install-pip%20install%20cjrh_math-ff69b4.svg https://img.shields.io/pypi/v/cjrh_math.svg https://img.shields.io/badge/calver-YYYY.MM.MINOR-22bfda.svg

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.

Metadata

Release files for cjrh_math 2017.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjrh_math 2017.11.1
File Size Uploaded Provenance
cjrh_math-2017.11.1.tar.gz 6.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cjrh_math 2017.11.1
File Interpreter ABI Platform
cjrh_math-2017.11.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.2 kB

Release files / cjrh_math-2017.11.1.tar.gz

Download URL cjrh_math-2017.11.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
60a3b9d1f4a42e937aa97d2d2a14f21db13822794aaf261a4ccb321574b4d3f1
BLAKE2b-256 checksum
How to use checksums
55e86d12983dd31a8b79982d1bf1ea5e660f524271dd33e3671962a8cd306764
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / cjrh_math-2017.11.1-py2.py3-none-any.whl

Download URL cjrh_math-2017.11.1-py2.py3-none-any.whl
Size 13.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
690e585cf87c578c538ca0964b36010f336940cd324a2f46fe0841274744952d
BLAKE2b-256 checksum
How to use checksums
950dbe5b26ae3a546838604bcb112ecd7f7e5013d9d3dfb3f5cdad970a4301c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cjrh_math 2017.11.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

2017.11.1 This release

2 release files No provenance

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