Public Member Functions | Protected Attributes | List of all members
o2scl::prob_dens_mdim_gaussian< vec_t, mat_t > Class Template Reference

A multi-dimensional Gaussian probability density function using a Cholesky decomposition. More...

#include <prob_dens_func.h>

Inheritance diagram for o2scl::prob_dens_mdim_gaussian< vec_t, mat_t >:
o2scl::prob_dens_mdim< vec_t >

Detailed Description

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
class o2scl::prob_dens_mdim_gaussian< vec_t, mat_t >

Given a (square) covariance matrix, $ \Sigma $, and a mean vector $ \mu $ the PDF is

\[ P(x) = \det \left( 2 \pi \Sigma \right)^{-1/2} \exp \left[ -\frac{1}{2} (x-\mu)^T \Sigma^{-1} (x-\mu) \right] \]

Given the Cholesky decomposition $ A A^{T} = \Sigma $, and a vector, $ z $ of samples from the standard Gaussian with 0 mean and unit variance, one can create a sample $ x $ from $ x = \mu + A z $ .

Note
This class inverts the matrix, necessary for computing the pdf, but not for sampling the distribution, so for large matrices the inversion can be a waste of computation if the pdf is not needed.

A separate class for the two-dimensional case is prob_dens_mdim_biv_gaussian .

Idea for Future:
Create alternate versions based on other matrix decompositions?

Definition at line 924 of file prob_dens_func.h.

Public Member Functions

virtual size_t dim () const
 The dimensionality.
 
 prob_dens_mdim_gaussian ()
 Create an empty distribution.
 
 prob_dens_mdim_gaussian (size_t p_ndim, vec_t &p_peak, mat_t &covar)
 Create a distribution from the covariance matrix.
 
void set (size_t p_ndim, vec_t &p_peak, mat_t &covar)
 Set the peak and covariance matrix for the distribution.
 
void set_alt (size_t p_ndim, vec_t &p_peak, mat_t &p_chol, mat_t &p_covar_inv, double p_norm)
 Alternate set function for use when covariance matrix has already been decomposed and inverted.
 
template<class vec_vec_t , class mat_col_t , class func_t >
void set_gproc (size_t n_dim, size_t n_init, vec_vec_t &x, vec_t &y, func_t &fcovar)
 Given a data set and a covariance function, construct probability distribution based on a Gaussian process which includes noise.
 
virtual double pdf (const vec_t &x) const
 The normalized density.
 
virtual double log_pdf (const vec_t &x) const
 The log of the normalized density.
 
virtual void operator() (vec_t &x) const
 Sample the distribution.
 

Protected Attributes

mat_t chol
 Cholesky decomposition.
 
mat_t covar_inv
 Inverse of the covariance matrix.
 
vec_t peak
 Location of the peak.
 
double norm
 Normalization factor, $ \det ( 2 \pi \Sigma)^{-1/2} $.
 
size_t ndim
 Number of dimensions.
 
vec_t q
 Temporary storage 1.
 
vec_t vtmp
 Temporary storage 2.
 
o2scl::prob_dens_gaussian pdg
 Standard normal.
 

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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).