kld_gaussian: Analytical KL divergence for two uni- or multivariate...

View source: R/kld-analytical.R

kld_gaussianR Documentation

Analytical KL divergence for two uni- or multivariate Gaussian distributions

Description

This function computes D_{KL}(p||q), where p\sim \mathcal{N}(\mu_1,\Sigma_1) and q\sim \mathcal{N}(\mu_2,\Sigma_2).

Usage

kld_gaussian(mu1, sigma1, mu2, sigma2)

Arguments

mu1

A numeric vector (mean of true Gaussian)

sigma1

A s.p.d. matrix (Covariance matrix of true Gaussian)

mu2

A numeric vector (mean of approximate Gaussian)

sigma2

A s.p.d. matrix (Covariance matrix of approximate Gaussian)

Value

A scalar (the Kullback-Leibler divergence)

Examples

kld_gaussian(mu1 = 1, sigma1 = 1, mu2 = 1, sigma2 = 2^2)
kld_gaussian(mu1 = rep(0,2), sigma1 = diag(2),
                mu2 = rep(1,2), sigma2 = matrix(c(1,0.5,0.5,1), nrow = 2))

kldest documentation built on May 29, 2024, 3 a.m.