skillfed

momentchi2

A collection of methods for computing the cdf of a weighted sum of chi-squared random variables.

momentchi2 v0.1.8 276.6K downloads/30d#8,161 on PyPI
Permissive license Abandoned released

What it is and what it does

momentchi2 provides four statistical approximation methods for computing the cumulative distribution function (CDF) of a weighted sum of chi-squared random variables. This is a specialized numerical problem in statistics where exact computation is expensive; the package trades exact accuracy for speed using moment-matching techniques. The four methods—Hall-Buckley-Eagleson, Satterthwaite-Welch, Wood's F, and Lindsay-Pilla-Basak—each have different strengths: Hall-Buckley-Eagleson is recommended for larger coefficient sets (over 100), while Lindsay-Pilla-Basak works better for smaller sets (up to 10). The package wraps scipy and numpy to deliver these approximations.

You call one of the four functions with a coefficient vector and quantile value(s), and it returns the approximate CDF. Input can be a scalar, list, or numpy array; output format matches input format. The Lindsay-Pilla-Basak method accepts a tunable parameter p (default 4) to trade accuracy for speed. The package is a Python port of the R package momentchi2 and is intended for researchers and practitioners who need fast, reasonably accurate CDF approximations rather than exact solutions.

Use it for:

  • Approximate CDF of weighted chi-squared sums in statistical hypothesis testing or variance component estimation.
  • Fast numerical approximation in simulation studies where exact computation would be prohibitively slow.
  • Selecting among four moment-matching methods based on the size of your coefficient vector and accuracy requirements.
  • Batch evaluation of CDF at multiple quantile points using numpy arrays for vectorized performance.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Computes the cumulative distribution function of a weighted sum of chi-squared random variables using four moment-matching approximation methods: Hall-Buckley-Eagleson, Satterthwaite-Welch, Wood's F, and Lindsay-Pilla-Basak.

Yes, if you need a fast approximate CDF for weighted chi-squared sums and can tolerate two to three decimal place accuracy. No, if you require exact results, active maintenance, or modern package support—the project is abandoned (last release 2021-08-27) and may have compatibility issues with current scipy/numpy versions. Suitable for research or one-off analysis, risky for production systems.

Install

momentchi2 on PyPI

pip

pip install momentchi2

uv

uv add momentchi2

poetry

poetry add momentchi2

Installing momentchi2

Before you install

Low install friction with only numpy and scipy as dependencies. However, the package is abandoned—last release was 2021-08-27 with no updates since, so expect no maintenance or bug fixes.

License in practice

MIT license (permissive) means you can use, modify, and distribute the package freely with minimal restrictions, though you must include the license notice.

Quickstart

pip install momentchi2

from momentchi2 import hbe
import numpy as np

# Compute CDF for weighted chi-squared sum
result = hbe(np.array([1.5, 1.5, 0.5, 0.5]), np.array([0.627, 10.203]))

Requires Python 3.6 or later; numpy and scipy must be installed.

Verify before relying

  • Whether the package's accuracy claims (two to three decimal places) hold for your specific use case and coefficient configuration.
  • Current compatibility with modern scipy and numpy versions, given the package has not been updated since 2021.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies 2 — scipy, numpy
Maintenance abandoned — 1,813 days since the last release
First released
Downloads 276,649/month — #8,161 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: momentchi2-0.1.8-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

chi-squared weighted sum cdfmoment matching approximationchi-squared distributionstatistical approximation methodsquadratic form distributionweighted chi-squared cdf
statistical-approximationchi-squaredmoment-matching

More Mathematics packages