Skip to contents

Evaluates the density (or log-density) of a Gaussian mixture at one or more points.

Usage

dgmm(x, g, log = FALSE)

Arguments

x

A numeric matrix with one observation per row, or a length-p numeric vector (treated as a single observation).

g

A gmm (or gmm_fit) object.

log

Logical. If TRUE, return log-densities.

Value

A numeric vector of length nrow(x).

Examples

g <- gmm(weights = c(0.5, 0.5),
         means = list(c(-1, 0), c(1, 0)),
         covariances = list(diag(2), diag(2)))
dgmm(c(0, 0), g)
#> [1] 0.09653235
dgmm(c(0, 0), g, log = TRUE)
#> [1] -2.337877