Skip to main content

GMM recovery impl by V.G.Spokoiniy and David

Project description

GMM-Recovery: Spokoiny's Method of Moments for Isotropic Gaussian Mixture Models

A lightweight Python implementation of the Generalized Method of Moments (GMM) for recovering the parameters of multivariate isotropic Gaussian mixture models, adhering strictly to the theoretical framework proposed by V. Spokoiny (2026).

1. Mathematical Formulation

Let $X_1, \dots, X_n \in \mathbb{R}^d$ be independent and identically distributed (i.i.d.) random vectors drawn from an isotropic Gaussian mixture with density:

$$f(x, \theta) = \sum_{k=1}^K \mu_k \sigma_k^{-d} \varphi\left(\frac{x - m_k}{\sigma_k}\right)$$

where $\varphi(x) = (2\pi)^{-d/2} \exp(-|x|^2 / 2)$, and the vector of unknown parameters is defined as:

$$\theta = {(m_k, \sigma_k, \mu_k), k = 1, \dots, K}, \quad \mu_k \geq 0, \quad \sum_{k=1}^K \mu_k = 1$$

1.1. System of Moments and Test Functions

Given a family of test functions ${\omega_j(x), j = 1, \dots, J}$, we define the empirical observables (moments):

$$Z_j = \frac{1}{n} \sum_{i=1}^n \omega_j(X_i), \quad j = 1, \dots, J$$

The test functions are constructed as isotropic Gaussian kernels centered at points $\xi_j \in \mathbb{R}^d$ with scale parameters $s_j > 0$:

$$\omega_j(x) = \mathcal{K}\left(\frac{x - \xi_j}{s_j}\right) = \exp\left( -\frac{|x - \xi_j|^2}{2s_j^2} \right)$$

The theoretical expectation $M_j(\theta) = \mathbb{E}[\omega_j(X)] = \int \omega_j(x)f(x, \theta)dx$ under the isotropic kernel yields a closed-form analytical expression (Lemma 1.1):

$$\psi_j(m_k, \sigma_k) = \left( 1 + \frac{\sigma_k^2}{s_j^2} \right)^{-d/2} \exp\left{ - \frac{|m_k - \xi_j|^2}{2(\sigma_k^2 + s_j^2)} \right}$$

$$M_j(\theta) = \sum_{k=1}^K \mu_k \psi_j(m_k, \sigma_k)$$


2. Alternating Minimization Procedure

To ensure numerical stability and eliminate the direct non-linear dependency on the moment residuals, we introduce an auxiliary image parameter $z \in \mathbb{R}^J$ and rewrite the extended objective function as (Equation 1.7):

$$\mathcal{L}(\theta, z) = \frac{1}{2} |Z - z|^2 + \frac{1}{2} |z - M(\theta)|^2$$

The optimization is solved via alternating minimization at each outer iteration $t$:

  1. Step over $z$ (analytical): Updates the surrogate target by taking the average of empirical and estimated moments:

    $$z^{(t+1)} = \frac{1}{2}\left( Z + M(\theta^{(t)}) \right)$$

  2. Step over $\theta$ (numerical): Minimizes the smooth quadratic discrepancy:

    $$\theta^{(t+1)} = \arg\min_{\theta} \frac{1}{2} |z^{(t+1)} - M(\theta)|^2$$

    This step is computed using the L-BFGS-B quasi-Newton optimizer with analytical gradients.

2.1. Parameter Constraints and Reparameterization

To enforce strict boundary conditions during the optimization steps:

  • Mixture weights $\mu$ are parameterized via a softmax mapping: $\mu_k = e^{\eta_k} / \sum_l e^{\eta_l}$ for unconstrained parameters $\eta \in \mathbb{R}^K$.
  • Standard deviations $\sigma$ are kept positive using an exponential map: $\sigma_k = e^{\lambda_k}$ for $\lambda_k \in \mathbb{R}$.

3. Test Function Selection Strategy

The library provides two strategies for generating the centers ${\xi_j}$ and scales ${s_j}$ of the test functions:

  1. Data-dependent (Default): Test centers are perturbed versions of the actual data points, $\xi_j = X_j + \varepsilon_j$, where $\varepsilon_j \sim \mathcal{N}(0, \sigma_0^2 I_d)$. The bandwidths $s_j$ are adaptively set proportional to the median distance to the nearest neighbor. This concentrates moments in regions with high data density.
  2. Multiscale (Optional): If a specific number of test functions $q$ is requested, they are sampled over a subset of the dataset and distributed across three bandwidth scales $s_j \in {0.3s_0, s_0, 3s_0}$ to capture both fine and coarse properties of the mixture structure.

4. Quick Start

Installation

pip install gmm_recovery

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_recovery-0.1.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

gmm_recovery-0.1.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file gmm_recovery-0.1.2.tar.gz.

File metadata

  • Download URL: gmm_recovery-0.1.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for gmm_recovery-0.1.2.tar.gz
Algorithm Hash digest
SHA256 67efa0d6e763796901b81fc769d1b71684ee599ddaad627b565d83328642b2f0
MD5 3082925acaf7d83aed7dc86bb3cea1a5
BLAKE2b-256 fbd34d6cbb64251a55cb8429de2752da6d60f1f45a35619649474338bda6bc23

See more details on using hashes here.

File details

Details for the file gmm_recovery-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gmm_recovery-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for gmm_recovery-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ac99ace1e75348b6410867337ffc4dc29700e1d01e7176093c32298d41ff92
MD5 a53de0d112507ba654f9b5a75e0fc86a
BLAKE2b-256 7aa3e4da9f229b1769d2570e069814713b2e9fb423d90b8769408df0b47f9106

See more details on using hashes here.

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