
Relative Entropy Between Two Gaussians (the ACI causal metric)
Source:R/relative-entropy.R
relative_entropy.RdComputes the Kullback-Leibler divergence
\(\mathcal{P}(p, q) = \int p \log(p / q)\) between two multivariate Gaussian
distributions \(p = \mathcal{N}(\mu_p, \Sigma_p)\) and
\(q = \mathcal{N}(\mu_q, \Sigma_q)\). This is the operational statistic of
Assimilative Causal Inference (ACI): with p the smoother posterior of a
hidden cause (using the future of the observed effect) and q the filter
posterior (past only), a non-zero value identifies the hidden variable as a
cause of the observed effect at that instant.
Details
The closed form for k-dimensional Gaussians is
$$\tfrac{1}{2}\left[\operatorname{tr}(\Sigma_q^{-1}\Sigma_p)
+ (\mu_q-\mu_p)^\top \Sigma_q^{-1} (\mu_q-\mu_p) - k
+ \log\frac{\det \Sigma_q}{\det \Sigma_p}\right].$$
The measure is non-negative, zero if and only if the two Gaussians coincide,
and asymmetric in p and q (it is a divergence, not a distance). It captures
differences in both mean and covariance and is invariant under any smooth
invertible reparameterisation of the state.
Covariance arguments accept a k x k matrix, a length-k variance vector
(diagonal covariance), or a scalar (isotropic). The reference covariance
\(\Sigma_q\) must be positive definite.