GPmix.GaussianMixtureParameterEstimator

class GPmix.GaussianMixtureParameterEstimator(n_comp, n_moments=None, epsilon=0.0)[source]

Bases: object

Estimate parameters of a univariate Gaussian mixture model (GMM) using the method of moments.

This estimator implements a numerically stable method-of-moments approach for univariate GMMs, using the log-sum-exp trick for moment calculations. It supports flexible initialization, simple parameter constraints, and optional normalization of the input data.

THIS IS STILL EXPERIMENTAL. USE WITH CAUTION.

Parameters:
  • n_comp (int) – Number of mixture components.

  • n_moments (int or None, optional) – Highest order of moment to consider. If None, defaults to 4 * n_comp - 2.

  • epsilon (float, optional) – Lower bound on mixture weights and bounds for means/variances used to improve numerical stability. If set to 0.0, no additional constraints are applied.

n_comp

Number of mixture components.

Type:

int

n_moments

Highest order of moment used during fitting.

Type:

int

epsilon

Lower bound/constraint strength used during fitting.

Type:

float

init_guess_

Initial parameter guess in the order: weights, means, variances.

Type:

ndarray of shape (3 * n_comp,)

Notes

The method of moments can be sensitive to both the choice of initialization and the moment order. The solver minimizes a system of moment equations via non-linear least squares. For stability, computed log-moments use the log-sum-exp trick.

fit(data, normalize=True, full_output=False)[source]

Fit data to univariate GMM using method of moment estimation

data

Sample data.

Type:

array-like of shape (sample size,)

normalize

If True, the already centered data will be transformed to having unit variance.

Type:

boolean, default = True.

full_output

If True, a comprehensive report of the (optimization) solver is returned, else only the estimates are returned.

Type:

boolean, default = False

Returns:

  • If ‘full_output = False’, returns an array of shape (3*n_comp,); ordered in the form weights, means, variance.

  • else if ‘full_output = True’, a comprehensive report on the (optimization) solver is returned.

Parameters:
log_sample_moments(data, order)[source]

Compute the log of sample moments using log-sum-exp trick

Parameters:
Return type:

float

log_theoretical_mixture_moments(parameters, order)[source]

Compute the log of theoretical moments of a univariate Gaussian mixture using log-sum-exp trick

Parameters:
Return type:

float

parameters

weights, means and variances of univatiate Gaussian, strictly this order: weights, means, variances

Type:

array-like of shape (3 * n_comp, )

order

order of moment

Type:

int

log_theoretical_moments(parameters, order)[source]

Compute the log of theoretical moments of a univariate Gaussian using log-sum-exp trick

Parameters:
Return type:

float

parameters

mean and variance of univatiate Gaussian, strictly this order: mean, variance

Type:

array-like of shape (2, )

order

order of moment

Type:

int