Learn R Programming

SSLfmm (version 0.1.0)

get_entropy: Per-Row Entropy of Posterior Cluster Probabilities

Description

Compute the Shannon entropy (in nats) of posterior membership probabilities for each observation, given a Gaussian mixture model. Posterior probabilities \(\tau_{ij}\) are obtained via get_clusterprobs().

Usage

get_entropy(dat, n, p, g, pi = NULL, mu = NULL, sigma = NULL, paralist = NULL)

Value

Numeric vector of length \(n\), the entropy per observation (in nats).

Arguments

dat

Numeric matrix \(n \times p\). The data matrix.

n

Integer. Number of rows in dat.

p

Integer. Number of columns (features) in dat.

g

Integer. Number of mixture components.

pi

Optional numeric vector length \(g\). Mixing proportions (sum to 1).

mu

Optional numeric matrix \(p \times g\). Column \(j\) is the mean of component \(j\).

sigma

Optional numeric matrix \(p \times p\) (shared covariance) or array \(p \times p \times g\) (component-specific covariances).

paralist

Optional list with elements pi, mu, sigma. If supplied, these take precedence over the corresponding explicit arguments.

See Also

get_clusterprobs

Examples

Run this code
  # Suppose you have get_clusterprobs(), and a fitted/pi, mu, sigma:
  n <- 100; p <- 2; g <- 2
  X <- matrix(rnorm(n * p), n, p)
  pi <- c(0.6, 0.4)
  mu <- cbind(c(0,0), c(1,1))
  Sigma <- array(0, dim = c(p, p, g))
  Sigma[,,1] <- diag(p); Sigma[,,2] <- diag(p)
  ent <- get_entropy(dat = X, n = n, p = p, g = g, pi = pi, mu = mu, sigma = Sigma)
  summary(ent)

Run the code above in your browser using DataLab