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
  • Mixture-weight fitting with forward, reverse, bidirectional, 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

For development, install it from a local checkout:

python -m pip install -e .

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.MonteCarlo(sampling=50_000, rng=0))
print(result.value, result.monte_carlo_stats.standard_error)

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.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.1a5.tar.gz (37.4 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.1a5-py3-none-any.whl (56.6 kB view details)

Uploaded Python 3

File details

Details for the file gmm_divergence-0.0.1a5.tar.gz.

File metadata

  • Download URL: gmm_divergence-0.0.1a5.tar.gz
  • Upload date:
  • Size: 37.4 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.1a5.tar.gz
Algorithm Hash digest
SHA256 6420336186661f69ba1f8e380c4dbcc4c30b137a5c2a5312871970ea8565deb3
MD5 9005202ddb6742f9f25e7ecc659f9cb5
BLAKE2b-256 045b6086a5a886641efb273dde31689a58a004655e8217dd40871a1b609be671

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmm_divergence-0.0.1a5.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.1a5-py3-none-any.whl.

File metadata

File hashes

Hashes for gmm_divergence-0.0.1a5-py3-none-any.whl
Algorithm Hash digest
SHA256 010914e35ebf23cb57ac42ece54eabf93df8492efafcdd74025e0d48f2a6f9f6
MD5 481bcb19b5d44fea7a8a995281f6620f
BLAKE2b-256 ce471be228c68ca7d15988effaeca9664d7de763153e56e6ef62deaa0c9a72d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gmm_divergence-0.0.1a5-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