Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmm_divergence-0.0.1a6.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gmm_divergence-0.0.1a6-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

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

Hashes for gmm_divergence-0.0.1a6.tar.gz
Algorithm Hash digest
SHA256 0250441abd072008997c5b4c0ce5ca965cfc520b0be9b01766e32e226688369c
MD5 b03aaf313e8633bf647b46bedda1e402
BLAKE2b-256 90cf47b4d80b48eb06b67a2edb71d657223c8209585a7bd85ccd6d3c5dd71496

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmm_divergence-0.0.1a6.tar.gz:

Publisher: pypi.yml on davaxe/gmm-divergence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gmm_divergence-0.0.1a6-py3-none-any.whl.

File metadata

File hashes

Hashes for gmm_divergence-0.0.1a6-py3-none-any.whl
Algorithm Hash digest
SHA256 6321cefbbb3c92999b569c6769340d6ed1dbe56a0a59ced5804d4178293389ac
MD5 57e2edfc3c25550859bca6b87af2c79d
BLAKE2b-256 addeddb75bd974866a8389a4634053fe05f4b4a192f8a5e5aac4607831882fac

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmm_divergence-0.0.1a6-py3-none-any.whl:

Publisher: pypi.yml on davaxe/gmm-divergence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page