Fit weighted single Gaussians and Gaussian mixtures with separate structure and
method specifications. Observations are columns of a features × samples matrix.
Fitted models support logpdf, sampling, marginalization and conditional predict.
using StructuredGaussianMixtures, Random
X = randn(MersenneTwister(1), 10, 500)
spec = MixtureSpec(LowRankDiagonal(2), 4)
method = EM(covariance_method=CovarianceEM(maxiter=20), n_init=3)
gmm = fit(spec, method, X; rng=MersenneTwister(2))
posterior = predict(gmm, [0.2, -0.1], [1, 2], [3, 4])
# A single Gaussian uses the covariance solver directly.
gaussian = fit(FullCovariance(), Exact(), X)
# Explicit initialized state for continuation; fit! never reinitializes.
state = workspace(spec, method, gmm)
fit!(state, method, X)
state.reportFullCovariance(),DiagonalCovariance(), andIsotropicCovariance()useExact()covariance updates. Addtied=Tied(:covariance)toMixtureSpecfor one shared covariance with separate component means.LowRankDiagonal(r)usesCovarianceEM()without forming a dense covariance.LatentCovariance(r)supports single-GaussianCovarianceEM()fitting.LatentCovariance(r)withTied(:F,:D)supports jointEM(covariance_method=CovarianceEM()), learning shared loadings and residual noise, orPCAEM(latent_method=EM(...))for a fixed PCA projection. Both returnLatentMvNormalcomponents with explicit sharedFand component latent covariances.- All fitting paths accept
weights=...and fresh fits acceptrng=.... - Native
EMprovides convergence reports, restarts and weighted updates.responsibilities(gmm, X)returns posterior membership probabilities;predictcontinues to mean conditional prediction.
Install with Pkg.add("StructuredGaussianMixtures"). See the
fitting guide for the API, supported combinations,
initialization and migration from the former EM/FactorEM/PCAEM interface.
Banded precision models use fit(BandedPrecision(2), Exact(), X) or
fit(MixtureSpec(BandedPrecision(2), 3), EM(), X). Precision bandwidth follows
the feature order. Scoring uses compact bands, and conditioning preserves them
when all omitted variables are observed. See the
banded precision guide for regularization semantics
and dense marginalization fallbacks.