def MVG_DKL(M0,P0,M1,P1):
'''
KL divergence between two Gaussians
Example
-------
M = randn(10)
Q = randn(N,N)
P = Q.dot(Q.T)
MGV_DKL(M,P,M,P)
'''
MVG_check(M0,P0)
MVG_check(M1,P1)
N = len(M0)
M1M0 = M1-M0
return 0.5*(np.sum(P1*pinv(P0))+logdet(P0)-logdet(P1)-N+M1M0.T.dot(P1).dot(M1M0))
#return 0.5*(np.sum(np.diag(P1.dot(np.linalg.pinv(P0))))+logdet(P0)-logdet(P1)-N+M1M0.T.dot(P1).dot(M1M0))
评论列表
文章目录