Registry / data / momentchi2

momentchi2

JSON →
library0.1.8pypypi✓ verified 85d ago

A Python library for computing the cumulative distribution function (CDF) of a weighted sum of chi-squared random variables. Version 0.1.8 supports Imhof's method, Davies' method, and moment-based approximations. Developed by the PyPA, with monthly or less frequent releases.

pip install momentchi2
INSTALL
IMPORT
SIG · MOMENTCHI2
M
momentchi2
datapythonv0.1.8
Install
7.3s avg
Import
2454ms
Disk
230MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.528s · 230.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 7.3s · import 2.380s · 222MB
230MB installed
● package 230MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

momentchi2
import momentchi2
The library is a single module; no submodules are exposed.

Compute the CDF of a weighted sum of chi-squared random variables using Imhof's method. For other methods (e.g., Davies, moment-based), replace imhof with davies or moment_approximation.

import momentchi2 # Example: CDF of a weighted sum of chi-squared variables # weights and degrees of freedom df = [1, 2, 1] weights = [0.5, 0.3, 0.2] q = 1.5 # Use Imhof's method p = momentchi2.imhof(q, weights, df) print(f"CDF value: {p:.6f}")
Debug
Known issues
gotchaThe library function names differ from the original R package 'momentchi2'. Ensure you use Python function names: imhof, davies, moment_approximation, etc.
fix
Use import momentchi2 and call momentchi2.imhof(...) etc.
affects: >=0.1.0
deprecatedThe 'davies' method may be deprecated in future versions due to numerical stability issues. Prefer 'imhof' for reliable results.
fix
Use momentchi2.imhof() instead of momentchi2.davies().
affects: >=0.1.0
gotchaWeights and degrees of freedom vectors must be of equal length, otherwise an unhelpful ValueError is raised.
fix
Ensure len(weights) == len(df). If df is a scalar, repeat it to match the number of weights.
affects: >=0.1.0
Errors
Common errors & fixes
ValueError: The weights and degrees of freedom must have the same length
Mismatched lengths of weights and df arrays.
fix
Check that len(weights) == len(df) and adjust accordingly.
ImportError: No module named 'momentchi2'
The library is not installed or the package name is misspelled.
fix
Run pip install momentchi2 and ensure the correct Python environment is used.
Upgrade
Version history
0.1.8latest on PyPI · released Aug 27, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
momentchi2 — pip install momentchi2 · libregistry