Skip to main content

Truncated Guassian Mixtures

Documentation PyPI version

Fit data to mixtures of truncated multivariate gaussians

   p(x) = \sum_k w_k\  \phi_{[{\bf a}, {\bf b}]}({\bf x} | \boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k)

where ${\bf a}$ and ${\bf b}$ are the bounding corners of the hypercube we would like to truncate the gaussian in. This package supports

  • Full, Diagonal and Block diagonal covariances for each component
  • Inteface to allow one to perform the fit in some latent space given by a user-defined transformation, and carry along any target labels
  • Sampling and pdf evaluation from the resultant fit

Quick Start

You can install this library using

pip install truncatedgaussianmixtures

You can then import truncatedgaussianmixtures. At the first import it may take a while, since this will create a local julia installation. This will only happen once at the first ever import.

The main function to use is fit_gmm. The following is a simple example use case.

   import pandas as pd
   from truncatedgaussianmixtures import fit_gmm

   # Generate some data
   df = pd.DataFrame(np.random.randn(80_000, 2), columns=["x", "y"])
   
   # Truncated it to the unit square
   cond = (df['x'] < 1) & (df['x'] > 0)  
   cond &= (df['y'] < 1) & (df['y'] > 0)
   df = df[cond]

   # Fit it a truncated gaussian mixture model to it
   gmm = fit_gmm(data = df,      # data to fit to
                 N    = 1,       # Number of components of the mixture model
                 a    = [0,0],   # lower corner of the truncation
                 b    = [1,1],   # upper corner of the truncation
                 cov  = "diag"   # covariance structure: any of ("diag", "full")
          )

   # Sample from the gmm
   df_fit = gmm.sample(len(df));

   # Evaluate it at different points
   gmm.pdf(np.array([0,0]))

Metadata

Release files for truncatedgaussianmixtures 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for truncatedgaussianmixtures 0.1.7
File Size Uploaded Provenance Actions
truncatedgaussianmixtures-0.1.7.tar.gz 9.8 kB Without provenance Details for truncatedgaussianmixtures-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for truncatedgaussianmixtures 0.1.7
File Interpreter ABI Platform Actions
truncatedgaussianmixtures-0.1.7-py3-none-any.whl Python 3 none any Details for truncatedgaussianmixtures-0.1.7-py3-none-any.whl

Total release size: 22.8 kB

Release files / truncatedgaussianmixtures-0.1.7.tar.gz

Download URL truncatedgaussianmixtures-0.1.7.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fb44380e7944e1f37574e36920ddbcbba5629a46b5fd8ce04f43a59755eb71f9
BLAKE2b-256 checksum
How to use checksums
d84e471974c02838c5f6ac51915db15eb17860257e174b6f02e3c15a447e14e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / truncatedgaussianmixtures-0.1.7-py3-none-any.whl

Download URL truncatedgaussianmixtures-0.1.7-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a6964e1ec8a61230324f7964768cfd931621119e64e1bb64a2977fbd8359b07
BLAKE2b-256 checksum
How to use checksums
292721d5276cba34400a40dc12b88d925ef03e0c702c6614ad9ab5f88eae0c5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for truncatedgaussianmixtures 0.1.7

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page