https://github.com/ntessore/online-stats

Python micropackage with an online algorithm for mean, variance, and covariance

https://github.com/ntessore/online-stats

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.3%) to scientific vocabulary

Keywords

online-algorithms online-covariance online-mean online-variance
Last synced: 9 months ago · JSON representation

Repository

Python micropackage with an online algorithm for mean, variance, and covariance

Basic Info
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • Open Issues: 1
  • Releases: 4
Topics
online-algorithms online-covariance online-mean online-variance
Created over 3 years ago · Last pushed 10 months ago
Metadata Files
Readme License

README.md

online-stats — Online algorithm for mean, variance, and covariance

The online-stats Python package contains a single function online_stats.add_sample() which updates a sample mean given a new sample, as well as optionally the sample variance and the sample covariance matrix.

The package has no dependencies, as the online_stats.add_sample() function works with any input data type that supports in-place addition and fancy slicing.

Usage

```py

import numpy as np

the package

import online_stats

online algorithm for the mean

start from zero

mu = np.zeros(4)

generate samples and compute their mean

for i in range(1000): ... x = np.random.normal([0.1, 0.3, 0.5, 0.7]) ... onlinestats.addsample(i, x, mu) ...

the mean is computed in place

print(mu) [0.08804402 0.25896929 0.44891264 0.73418769]

compute the variance

mu = np.zeros(4) var = np.zeros(4) for i in range(1000): ... x = np.random.normal([0.1, 0.3, 0.5, 0.7], [0.2, 0.4, 0.6, 0.8]) ... onlinestats.addsample(i, x, mu, var=var) ... print(mu) [0.09854301 0.29509305 0.4777673 0.70008311] print(var**0.5) [0.19900518 0.4012857 0.59267129 0.81856542]

compute the covariance matrix

mu = np.zeros(4) cov = np.zeros((4, 4)) for i in range(100000): ... x = np.random.multivariatenormal([0.1, 0.3, 0.5, 0.7], ... [[0.2, 0.02, 0.04, 0.06], ... [0.02, 0.4, 0.06, 0.08], ... [0.04, 0.06, 0.6, 0.10], ... [0.06, 0.08, 0.10, 0.8]]) ... onlinestats.addsample(i, x, mu, cov=cov) ... print(mu) [0.10095607 0.30486108 0.50113141 0.69912377] print(cov) [[0.20101406 0.02105503 0.0382198 0.06220174] [0.02105503 0.39909545 0.06192678 0.0791239 ] [0.0382198 0.06192678 0.59960537 0.1082596 ] [0.06220174 0.0791239 0.1082596 0.80071002]]

```

Owner

  • Name: Nicolas Tessore
  • Login: ntessore
  • Kind: user
  • Location: UK
  • Company: University College London

cosmology and statistics on the sphere

GitHub Events

Total
  • Watch event: 1
  • Delete event: 6
  • Issue comment event: 2
  • Push event: 6
  • Pull request event: 13
  • Create event: 6
Last Year
  • Watch event: 1
  • Delete event: 6
  • Issue comment event: 2
  • Push event: 6
  • Pull request event: 13
  • Create event: 6

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 17 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.33
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 17 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.33
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • microprediction (1)
Pull Request Authors
  • dependabot[bot] (6)
Top Labels
Issue Labels
Pull Request Labels
dependencies (6)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 163 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
pypi.org: online-stats

Online algorithm for mean, variance, and covariance.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 163 Last month
Rankings
Dependent packages count: 7.5%
Forks count: 30.2%
Average: 36.6%
Stargazers count: 39.1%
Dependent repos count: 69.6%
Maintainers (1)
Last synced: 9 months ago

Dependencies

.github/workflows/publish.yml actions
  • actions/checkout v3 composite
  • pypa/gh-action-pypi-publish v1.6.4 composite
pyproject.toml pypi