TMB Documentation  v1.9.11
List of all members
density::PROJ_t< distribution > Class Template Reference

Projection of multivariate gaussian variable. More...

#include <density.hpp>

Detailed Description

template<class distribution>
class density::PROJ_t< distribution >

Projection of multivariate gaussian variable.

Preserves sparseness if possible. Generally it is not.

Given a gaussian density f:R^n -> R.
Given an integer vector "proj" with elements in 1,...,n.
Construct the mariginal density of "x[proj]".

Let x=[x_A]
with precision
    Q=[Q_AA  Q_AB]
      [Q_BA  Q_BB]
and assume that proj=A.
The marginal density is (with notation 0:=0*x_B )
Now see that
1. p(x_A,0) is easy because full precision is sparse.
2. p(0|x_A) is N(-Q_BB^-1 * Q_BA x_A,  Q_BB^-1) so
   p(0|x_A) = |Q_BB|^.5 * exp(-.5*x_A Q_AB * Q_BB^-1 * Q_BA x_A)

   Trick to evaluate this with what we have available:
   Note 1: Q_BA x_A = [0 I_BB] * full_jacobian([ x_A  ]  
                                               [ 0    ] )

           Call this quantity "y_B" we have
           p(0|x_A) = |Q_BB|^.5 * exp(-.5*y_B' * Q_BB^-1 * y_B)

   Note 2: Consider now a density with _covariance_ Q_BB 
           phi(y)=|Q_BB|^-.5 * exp(-.5*y' * Q_BB^-1 * y)
           phi(y)/phi(0)^2=|Q_BB|^.5 * exp(-.5*y' * Q_BB^-1 * y)
           which is actually the desired expression of p(0|x_A).

Negative log-density of A-marginal is
-log p(x_A,0) + log phi(y) - 2*log(phi(0))
= f(x_A,0) - dmvnorm(y_B) + 2*dmvnorm(0)

Definition at line 1297 of file density.hpp.

The documentation for this class was generated from the following file:
License: GPL v2