GPmix.GaussianMixtureParameterEstimator
- class GPmix.GaussianMixtureParameterEstimator(n_comp, n_moments=None, epsilon=0.0)[source]
Bases:
objectEstimate 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 to4 * 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.
- 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
- log_theoretical_mixture_moments(parameters, order)[source]
Compute the log of theoretical moments of a univariate Gaussian mixture using log-sum-exp trick
- parameters
weights, means and variances of univatiate Gaussian, strictly this order: weights, means, variances
- Type:
array-like of shape (3 * n_comp, )