Skip to content

Instantly share code, notes, and snippets.

View keizerzilla's full-sized avatar
💯
🏁

Artur Rodrigues keizerzilla

💯
🏁
  • Brasil
  • 07:50 (UTC -03:00)
View GitHub Profile
@ChuaCheowHuan
ChuaCheowHuan / mvg_KL.py
Created April 20, 2020 06:38
KL divergence for multivariate normal distributions
def kl_mvn(m0, S0, m1, S1):
"""
https://stackoverflow.com/questions/44549369/kullback-leibler-divergence-from-gaussian-pm-pv-to-gaussian-qm-qv
The following function computes the KL-Divergence between any two
multivariate normal distributions
(no need for the covariance matrices to be diagonal)
Kullback-Liebler divergence from Gaussian pm,pv to Gaussian qm,qv.
Also computes KL divergence from a single Gaussian pm,pv to a set