TMB Documentation  v1.9.1
Public Member Functions | List of all members
density::MVNORM_t< scalartype_ > Class Template Reference

Multivariate normal distribution with user supplied covariance matrix. More...

#include <density.hpp>

Public Member Functions

matrixtype cov ()
 Covariance matrix extractor. More...
 
scalartype operator() (vectortype x)
 Evaluate the negative log density.
 
scalartype operator() (vectortype x, vectortype keep)
 Evaluate projected negative log density. More...
 

Detailed Description

template<class scalartype_>
class density::MVNORM_t< scalartype_ >

Multivariate normal distribution with user supplied covariance matrix.

Class to evaluate the negative log density of a mean zero multivariate Gaussian variable with general covariance matrix Sigma. Intended for small dense covariance matrices.

matrix<Type> Sigma(3,3);
Sigma.fill(0.1); // Fill the whole matrix
Sigma.diagonal() *= 10.0; // Multiply diagonal by 10 to positive definite Sigma
vector<Type> x0(3); // Point of evaluation
x0.fill(0.0); // Initialize x0 to be zero
MVNORM_t<Type> N_0_Sigma(Sigma); // N_0_Sigma is now a Distribution
res = N_0_Sigma(x0); // Evaluates (neg. log) density at x
Examples:
laplace.cpp, matern.cpp, multivariate_distributions.cpp, mvrw.cpp, sam.cpp, spatial.cpp, TMBad/sam.cpp, TMBad/spatial.cpp, and validation/MVRandomWalkValidation.cpp.

Definition at line 112 of file density.hpp.

Member Function Documentation

§ cov()

template<class scalartype_>
matrixtype density::MVNORM_t< scalartype_ >::cov ( )
inline

Covariance matrix extractor.

Typical use:

matrix<Type> Sigma(3,3);
MVNORM_t<Type> N_0_Sigma(Sigma); // N_0_Sigma is now a Distribution
N_0_Sigma.cov(); // Returns covariance matrix (Sigma in this case)

Useful for classes such as UNSTRUCTURED_CORR_t that inherits from MVNORM_t.

Definition at line 134 of file density.hpp.

§ operator()()

template<class scalartype_>
scalartype density::MVNORM_t< scalartype_ >::operator() ( vectortype  x,
vectortype  keep 
)
inline

Evaluate projected negative log density.

Parameters
keepVector of 0/1 indicating marginal to evaluate.

Definition at line 162 of file density.hpp.


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