gaussian_mixture_em: Gaussian Mixture EM - direct R port of GaussianMixture.m...

View source: R/gaussian_mixture.R

gaussian_mixture_emR Documentation

Gaussian Mixture EM – direct R port of GaussianMixture.m (Bowman CLUSTER)

Description

Fits a K-component univariate Gaussian mixture using the same EM algorithm bundled with CharAnalysis v1.1 and v2.0 (Bowman CLUSTER implementation). Replicates three key behaviours that distinguish it from mclust:

Usage

gaussian_mixture_em(x, k = 2L)

Arguments

x

Numeric vector of observations (the C_peak values in the window).

k

Integer number of components (default 2).

Details

  1. First/last-point initialisation: for K = 2, component means are seeded at the first and last elements of the input data vector (not at sorted min/max; the data are in time order). This is the initMixture() behaviour from MATLAB.

  2. Loose convergence criterion: EM stops when the per-step log-likelihood gain falls to or below \epsilon = 0.01 \times L_c \times \log N where L_c = 3 for univariate data. This is much looser than the mclust default (10^{-5}) and causes MATLAB to freeze closer to the initial configuration.

  3. Variance regularisation: a small floor R_{\min} = \bar{\sigma}^2 / 10^5 is added to each component variance after every M-step, preventing degenerate (zero-variance) solutions.

Because CharAnalysis always calls GaussianMixture(X, 2, 2, false) (i.e.\ finalK = initK = 2), the MDLReduceOrder() path is never exercised and is therefore not implemented here.

Value

Named list:

mu

Numeric vector length k: component means sorted ascending.

sigma

Numeric vector length k: component standard deviations (= sqrt of fitted variance), sorted to match mu.

prop

Numeric vector length k: mixing proportions, sorted to match mu.

loglik

Scalar: log-likelihood at convergence.

See Also

[char_thresh_local()], [char_thresh_global()]


CharAnalysis documentation built on May 3, 2026, 5:06 p.m.