Skip to main content

pytest pytest

OMoment: Efficient online calculation of statistical moments

OMoment package calculates moments of statistical distributions (mean and variance) in online or distributed settings.

  • Suitable for large data – works well with numpy and Pandas and in distributed setting.

  • Moments calculated from different parts of data can be easily combined or updated for new data (supports addition of results).

  • Objects are lightweight, calculation is done in numpy if possible.

  • Weights for data can be provided.

  • Invalid values (NaNs, infinities are omitted by default).

Typical application is calculation of means and variances of many chunks of data (corresponding to different groups or to different parts of the distributed data), the results can be analyzed on level of the groups or easily combined to get exact moments for the full dataset.

Basic example

from omoment import OMeanVar
import numpy as np
import pandas as pd

rng = np.random.default_rng(12354)
g = rng.integers(low=0, high=10, size=1000)
x = g + rng.normal(loc=0, scale=10, size=1000)
w = rng.exponential(scale=1, size=1000)

# calculate overall moments
OMeanVar(x, weight=w)
# should give: OMeanVar(mean=4.6, var=108, weight=1.08e+03)

# or calculate moments for every group
df = pd.DataFrame({'g': g, 'x': x, 'w': w})
omvs = df.groupby('g').apply(OMeanVar.of_frame, x='x', w='w')

# and combine group moments to obtain the same overall results
OMeanVar.combine(omvs)

# addition is also supported
omvs.loc[0] + omvs.loc[1]

At the moment, only univariate distributions are supported. Bivariate or even multivariate distributions can be efficiently processed in a similar fashion, so the support for them might be added in the future. Moments of multivariate distributions would also allow for linear regression estimation and other statistical methods (such as PCA or regularized regression) to be calculated in a single pass through large distributed datasets.

Documentation

Metadata

Release files for omoment 0.1.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 omoment 0.1.1
File Size Uploaded
omoment-0.1.1.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for omoment 0.1.1
File Interpreter ABI Platform
omoment-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / omoment-0.1.1.tar.gz

Download URL omoment-0.1.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2c475591c5ee5ce4487a6eb702ed2b0339a6f78eaa2f0d29ba826abdde7a5014
BLAKE2b-256 checksum
How to use checksums
6fba79a26a8c63f87fa654bffa40cea67e92bd0f0565fad7525ffc185b7030ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release files / omoment-0.1.1-py3-none-any.whl

Download URL omoment-0.1.1-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3acff6555f3996545d1fe37904c1347c63b1e7038a096212e2e52b31d71c5cab
BLAKE2b-256 checksum
How to use checksums
ae4cdac69015575b20411cdf55ccb8c5c080b2bf497c43c8288226827b9c159e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release history Release notifications | RSS feed

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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