KL Divergence between two multivariate normal distributions(使用了trace 和Expection的性质)

http://stats.stackexchange.com/questions/60680/kl-divergence-between-two-multivariate-gaussians

I give a detailed derivation process for the KL Divergence between two multivariate normal distributions.
Given p(x)N(μ1,Σ1),q(x)N(μ2,Σ2) , we need to solve the KL KL=[log(p(x))log(q(x))] p(x) dx

Firstly, we have the multivariate normal distribution pdf,

p(x)=(2π)k2|Σ1|12exp{12(xμ1)TΣ11(xμ1)}

logp(x)=k2log2π12log|Σ1|12(xμ1)TΣ11(xμ1)

logq(x)=k2log2π12log|Σ2|12(xμ2)TΣ12(xμ2)

From the reference link above, we know a general derivation,

KL=[12log|Σ2||Σ1|12(xμ1)TΣ11(xμ1)+12(xμ2)TΣ12(xμ2)]×p(x)dx=12log|Σ2||Σ1|12tr {E[(xμ1)(xμ1)T] Σ11}+12E[(xμ2)TΣ12(xμ2)]=12log|Σ2||Σ1|12tr {Id}+12(μ1μ2)Σ12(μ1μ2)+12tr{Σ12Σ1}=12[log|Σ2||Σ1|d+tr(Σ12Σ1)+(μ2μ1)TΣ12(μ2μ1)].

Here, I give the detailed process for 12(xμ1)TΣ11(xμ1)p(x)dx and 12(xμ2)TΣ12(xμ2)p(x)dx .

Trace and Expectation Tricks

Given x is a scalar value, E(x)=E(tr(x)) since the trace of a scalar value is the scalar itself. Specially, for the expectation of quadratic form, E(xTAx)=E(tr(xTAx))=E(tr(AxxT))=tr(E(AxxT)) based on the properties below. After adding the trace symbol, we can exchange the position within the quadratic form.

tr(AB)=tr(BA)

tr(ABC)=tr(BCA)

tr(ABC)=tr(CAB)

tr(ABC)tr(ACB)

E(tr(x))=(tr(E(x))
, Expectation symbol can be exchanged by trace.

Part 1

12(xμ1)TΣ11(xμ1)p(x)dx=Ep(12(xμ1)TΣ11(xμ1))the expectation here is related to p(x) rather than q(x)=Ep(tr(12(xμ1)TΣ11(xμ1)))=Ep(tr(12(xμ1)(xμ1)TΣ11))=tr(Ep(12(xμ1)(xμ1)TΣ11))=tr(Ep[(xμ1)(xμ1)T]12Σ11)the definition of covariance matrix=tr(Σ112Σ11)=tr(Id)=d

Part2

12(xμ2)TΣ12(xμ2)×p(x)dx=12[(xμ1)+(μ1μ2)]TΣ12[(xμ1)+(μ1μ2)]×p(x)dx=12{(xμ1)TΣ12(xμ1)+2(xμ1)TΣ12(μ1μ2)+(μ1μ2)TΣ12(μ1μ2)}×p(x)dx=tr(Σ12Σ1)+ (μ1μ2)TΣ12(μ1μ2)

你可能感兴趣的:(KL Divergence between two multivariate normal distributions(使用了trace 和Expection的性质))