Utilities for estimating divergences between Gaussian mixture models.
Project description
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, method=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_mixture_weights(
p, candidates, objective=gd.fitting.MomentMatching(fit_second_moments=True)
)
print(fit.weights)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gmm_divergence-0.0.1a6.tar.gz.
File metadata
- Download URL: gmm_divergence-0.0.1a6.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0250441abd072008997c5b4c0ce5ca965cfc520b0be9b01766e32e226688369c
|
|
| MD5 |
b03aaf313e8633bf647b46bedda1e402
|
|
| BLAKE2b-256 |
90cf47b4d80b48eb06b67a2edb71d657223c8209585a7bd85ccd6d3c5dd71496
|
Provenance
The following attestation bundles were made for gmm_divergence-0.0.1a6.tar.gz:
Publisher:
pypi.yml on davaxe/gmm-divergence
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmm_divergence-0.0.1a6.tar.gz -
Subject digest:
0250441abd072008997c5b4c0ce5ca965cfc520b0be9b01766e32e226688369c - Sigstore transparency entry: 2059937289
- Sigstore integration time:
-
Permalink:
davaxe/gmm-divergence@13ae9eb6572a4598b302d48d70d40b33a572b787 -
Branch / Tag:
refs/tags/v0.0.1.a6 - Owner: https://github.com/davaxe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@13ae9eb6572a4598b302d48d70d40b33a572b787 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gmm_divergence-0.0.1a6-py3-none-any.whl.
File metadata
- Download URL: gmm_divergence-0.0.1a6-py3-none-any.whl
- Upload date:
- Size: 58.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6321cefbbb3c92999b569c6769340d6ed1dbe56a0a59ced5804d4178293389ac
|
|
| MD5 |
57e2edfc3c25550859bca6b87af2c79d
|
|
| BLAKE2b-256 |
addeddb75bd974866a8389a4634053fe05f4b4a192f8a5e5aac4607831882fac
|
Provenance
The following attestation bundles were made for gmm_divergence-0.0.1a6-py3-none-any.whl:
Publisher:
pypi.yml on davaxe/gmm-divergence
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmm_divergence-0.0.1a6-py3-none-any.whl -
Subject digest:
6321cefbbb3c92999b569c6769340d6ed1dbe56a0a59ced5804d4178293389ac - Sigstore transparency entry: 2059937632
- Sigstore integration time:
-
Permalink:
davaxe/gmm-divergence@13ae9eb6572a4598b302d48d70d40b33a572b787 -
Branch / Tag:
refs/tags/v0.0.1.a6 - Owner: https://github.com/davaxe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@13ae9eb6572a4598b302d48d70d40b33a572b787 -
Trigger Event:
push
-
Statement type: