Skip to main content

Реализация обобщенного метода моментов для изотропного GMM

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 .

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.0.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.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gmm_recovery-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 f798bbc7d63bab3d08b177b044214f44602e32fced2602f32fa8ea4837fc28fd
MD5 7b47f59e1d34e73a0ce9a8126b303e2e
BLAKE2b-256 bb4b9ad3973df832e7da775b96b7943bbcdd19682bbe6fe3bc98b754489495f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gmm_recovery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 623d7289a85f024aae9f35ee8e64a8895d8b9a6851cbbb490b54ff791d8a2788
MD5 ce78bd72a9149ed53e77c17d46c8045a
BLAKE2b-256 3e5147b796c0da8bbaedf27ef22d3711aa6469316aeb8724b26f89d530856a97

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