powered by
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)\).
kld_gaussian(mu1, sigma1, mu2, sigma2)
A scalar (the Kullback-Leibler divergence)
A numeric vector (mean of true Gaussian)
A s.p.d. matrix (Covariance matrix of true Gaussian)
A numeric vector (mean of approximate Gaussian)
A s.p.d. matrix (Covariance matrix of approximate Gaussian)
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))
Run the code above in your browser using DataLab