Public Member Functions | List of all members
o2scl::prob_cond_mdim< vec_t > Class Template Referenceabstract

A multi-dimensional conditional probability density function. More...

#include <prob_dens_func.h>

Inheritance diagram for o2scl::prob_cond_mdim< vec_t >:
o2scl::prob_cond_mdim_fixed_step< vec_t > o2scl::prob_cond_mdim_gaussian< vec_t, mat_t > o2scl::prob_cond_mdim_indep< vec_t >

Detailed Description

template<class vec_t = boost::numeric::ublas::vector<double>>
class o2scl::prob_cond_mdim< vec_t >

Note that conditional probabilities are typically written $ P(A|B) $, i.e. the probability of $ A $ given $ B $ , so when sampling the conditional probability density you specify a vector in $ B $ (the "input") and get a randomly chosen vector in $ A $ (the "output") . O2scl arranges function parameters so that input parameters are first and output parameters are last, thus the first argument to the functions o2scl::prob_cond_mdim::pdf, o2scl::prob_cond_mdim::log_pdf o2scl::prob_cond_mdim::operator()(), and o2scl::prob_cond_mdim::log_metrop_hast is a vector from $ B $ as denoted above.

This class is experimental.

Definition at line 1146 of file prob_dens_func.h.

Public Member Functions

virtual size_t dim () const
 The dimensionality.
 
virtual double pdf (const vec_t &x_B, const vec_t &x_A) const =0
 The conditional probability.
 
virtual double log_pdf (const vec_t &x_B, const vec_t &x_A) const =0
 The log of the conditional probability.
 
virtual void operator() (const vec_t &x_B, vec_t &x_A) const =0
 Sample the distribution.
 
virtual double log_metrop_hast (const vec_t &x_B, vec_t &x_A) const
 Sample the distribution and return the log of the Metropolis-Hastings ratio. More...
 

Member Function Documentation

◆ log_metrop_hast()

template<class vec_t = boost::numeric::ublas::vector<double>>
virtual double o2scl::prob_cond_mdim< vec_t >::log_metrop_hast ( const vec_t &  x_B,
vec_t &  x_A 
) const
inlinevirtual

The Metropolis-Hastings ratio for a step beginning at $ x $ and ending at $ x^{\prime} $ is obeys

\[ \frac{P(x^{\prime})g(x|x^{\prime})}{P(x)g(x^{\prime}|x)} \]

thus this function computes

\[ \log \left[ \frac{g(x|x^{\prime})}{g(x^{\prime}|x)} \right] \]

and thus this function takes x_B as input, obtains a sample x_A and returns the value

log_pdf(x_A,x_B)-log_pdf(x_B,x_A);

To check this, imagine that $ g $ is independent of the "input" argument, so we have

\[ \log \left[ \frac{g(x)}{g(x^{\prime})} \right] \]

and then a Metropolis-Hastings step is more likely accepted if $ g(x^{\prime}) $ is an underestimate.

Definition at line 1191 of file prob_dens_func.h.


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).