bayespy.inference.vmp.nodes.gaussian.GaussianDistribution.compute_gradient

GaussianDistribution.compute_gradient(g, u, phi)[source]

Compute the standard gradient with respect to the natural parameters.

Gradient of the moments:

\mathrm{d}\overline{\mathbf{u}} &=
\begin{bmatrix}
  \frac{1}{2} \phi_2^{-1} \mathrm{d}\phi_2 \phi_2^{-1} \phi_1
  - \frac{1}{2} \phi_2^{-1} \mathrm{d}\phi_1
  \\
  - \frac{1}{4} \phi_2^{-1} \mathrm{d}\phi_2 \phi_2^{-1} \phi_1 \phi_1^{\mathrm{T}} \phi_2^{-1}
  - \frac{1}{4} \phi_2^{-1} \phi_1 \phi_1^{\mathrm{T}} \phi_2^{-1} \mathrm{d}\phi_2 \phi_2^{-1}
  + \frac{1}{2} \phi_2^{-1} \mathrm{d}\phi_2 \phi_2^{-1}
  + \frac{1}{4} \phi_2^{-1} \mathrm{d}\phi_1 \phi_1^{\mathrm{T}} \phi_2^{-1}
  + \frac{1}{4} \phi_2^{-1} \phi_1 \mathrm{d}\phi_1^{\mathrm{T}} \phi_2^{-1}
\end{bmatrix}
\\
&=
\begin{bmatrix}
  2 (\overline{u}_2 - \overline{u}_1 \overline{u}_1^{\mathrm{T}}) \mathrm{d}\phi_2 \overline{u}_1
  + (\overline{u}_2 - \overline{u}_1 \overline{u}_1^{\mathrm{T}}) \mathrm{d}\phi_1
  \\
  u_2 d\phi_2 u_2 - 2 u_1 u_1^T d\phi_2 u_1 u_1^T
  + 2 (u_2 - u_1 u_1^T) d\phi_1 u_1^T
\end{bmatrix}

Standard gradient given the gradient with respect to the moments, that is, given the Riemannian gradient \tilde{\nabla}:

\nabla =
\begin{bmatrix}
  (\overline{u}_2 - \overline{u}_1 \overline{u}_1^{\mathrm{T}}) \tilde{\nabla}_1
  + 2 (u_2 - u_1 u_1^T) \tilde{\nabla}_2 u_1
  \\
  (u_2 - u_1 u_1^T) \tilde{\nabla}_1 u_1^T
  +  u_1 \tilde{\nabla}_1^T (u_2 - u_1 u_1^T)
  + 2 u_2 \tilde{\nabla}_2 u_2
  - 2 u_1 u_1^T \tilde{\nabla}_2 u_1 u_1^T
\end{bmatrix}