gmm-divergence
Utilities for estimating divergences between Gaussian mixture models.
This package is under development. APIs, estimators, and numerical behavior may change between early releases.
Current Scope
The package currently includes:
- Typed Gaussian and Gaussian mixture representations
- Density and log-density evaluation for Gaussian mixtures
- Sampling from Gaussian mixtures
- KL divergence estimators based on closed-form Gaussian KL, Monte Carlo sampling, unscented sigma points, Gaussian approximations, and variational bounds
- Explicit sampling controls for drawn, reused, and stratified Monte Carlo samples
- Mixture-weight fitting with forward, reverse, bidirectional, Jensen-Shannon, and moment-matching objectives
- Covariance regularization utilities for diagonal loading, shrinkage, eigenvalue clipping, and low-rank approximation
Installation
This project is not yet intended for stable production use. A pre-release is available from PyPI:
python -m pip install gmm-divergence
Quick Example
import gmm_divergence as gd
p = gd.GaussianMixture.from_components(
[
gd.Gaussian.univariate(mean=-1.0, variance=0.5),
gd.Gaussian.univariate(mean=1.5, variance=1.0),
],
weights=[0.4, 0.6],
)
q = gd.GaussianMixture.from_components([
gd.Gaussian.univariate(mean=-0.8, variance=0.7),
gd.Gaussian.univariate(mean=1.8, variance=1.2),
])
result = gd.kl_divergence(
p, q, estimator=gd.divergence.MonteCarlo(sampling=gd.sampling.Draw(50_000, rng=0))
)
print(result.value, result.monte_carlo_stats.standard_error)
The top-level module keeps the common distribution classes and primary helper
functions. Configuration objects are grouped by domain, for example
gd.divergence.MonteCarlo, gd.sampling.Draw, gd.fitting.ForwardKL, and
gd.covariance.DiagonalLoading.
Fitting Mixture Weights
candidates = [
gd.Gaussian.univariate(mean=-1.0, variance=0.5),
gd.Gaussian.univariate(mean=1.5, variance=1.0),
]
fit = gd.fit_gaussian_mixture_weights(
p,
candidates,
method=gd.fitting.SoftmaxLBFGSB(),
objective=gd.fitting.MomentMatching(fit_second_moments=True),
)
print(fit.weights)
Metadata
Release files for gmm-divergence 0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gmm_divergence-0.0.0.tar.gz | 44.8 kB | With provenance | Details for gmm_divergence-0.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gmm_divergence-0.0.0-py3-none-any.whl | Python 3 | none | any | Details for gmm_divergence-0.0.0-py3-none-any.whl |
Total release size: 111.8 kB
Release files / gmm_divergence-0.0.0.tar.gz
| Download URL | gmm_divergence-0.0.0.tar.gz |
|---|---|
| Size | 44.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb7f1ed7cd750d2c419f6ace549cd6c3ae4370e0f74f216d77bd55039751b55c
|
|
BLAKE2b-256 checksum How to use checksums |
b7b2b771f85fa989ab078a0dd01215af6231f42e25d25fd483985f14c4f5b557
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / gmm_divergence-0.0.0-py3-none-any.whl
| Download URL | gmm_divergence-0.0.0-py3-none-any.whl |
|---|---|
| Size | 67.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96921047db72ba5bacb67bec9cc63bd0dc77196284e2def3dcc8ffa4ecabbcec
|
|
BLAKE2b-256 checksum How to use checksums |
bbdf534e9ebe7d4ae8fd7a76ba34a711e40c80f0c6a1327a981fa2ad945e1fe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logSecurity for gmm-divergence 0.0.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for gmm_divergence-0.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logA 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.