Skip to contents

Lightweight S7 class representing an N-component multivariate Gaussian mixture on \(\mathbb{R}^p\). Use gmm() to construct, dgmm() / rgmm() to evaluate or sample, and gmm_marginalise() / gmm_conditionalise() for closed-form operations.

Usage

gmm(
  weights = numeric(0),
  means = list(),
  covariances = list(),
  name = "gmm",
  metadata = list()
)

Arguments

weights

Numeric vector of length K, non-negative, summing to one.

means

List of length K, each element a length-p numeric vector.

covariances

List of length K, each element a p-by-p symmetric positive-definite numeric matrix.

name

Optional human-readable name.

metadata

Optional list of arbitrary metadata (regime tags, diagnostic snapshots, etc.).

Value

An S7 object inheriting from gmm.

Examples

g <- gmm(
  weights = c(0.4, 0.6),
  means = list(c(-1, 0), c(1, 0)),
  covariances = list(diag(2), diag(2))
)
g
#> <gmm>: K = 2 components in p = 2 dimensions
#>   [1] w = 0.4000, |mu| = 1.0000, tr(Sigma) = 2.0000
#>   [2] w = 0.6000, |mu| = 1.0000, tr(Sigma) = 2.0000