Class prob_cond_mdim (o2scl)¶
-
template<class
vec_t
= boost::numeric::ublas::vector<double>>
classo2scl
::
prob_cond_mdim
¶ A multi-dimensional conditional probability density function.
Note that conditional probabilities are typically written \( P(A|B) \), i.e. the probability of \( A \) given \( B \). arranges the function parameters for the functions o2scl::prob_cond_mdim::pdf, o2scl::prob_cond_mdim::log_pdf o2scl::prob_cond_mdim::operator()(), so that \( B \) is given first, and \( A \) is second.
o2scl::prob_cond_mdim::log_metrop_hast is a vector from \( B \) as denoted above.
This class is experimental.
Public Functions
-
size_t
dim
() const¶ The dimensionality.
-
double
pdf
(const vec_t &x_B, const vec_t &x_A) const = 0¶ The conditional probability of x_A given x_B, i.e. \( P(A|B) \).
-
double
log_pdf
(const vec_t &x_B, const vec_t &x_A) const = 0¶ The log of the conditional probability of x_A given x_B i.e. \( \log [P(A|B)] \).
-
double
log_metrop_hast
(const vec_t &x, vec_t &x_prime) const¶ Sample the distribution and return the log of the Metropolis-Hastings ratio.
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)} \]taking the log, this gives\[ \log[P(x^{\prime})] - \log[P(x)] + \log \left[ \frac{g(x|x^{\prime})}{g(x^{\prime}|x)} \right] \]thus this function computes\[ \log \left[ g(x|x^{\prime}) \right] - \log \left[ g(x^{\prime}|x) \right] \]and thus, to keep a similar notation to prob_cond_mdim::pdf() where \( g(x^{\prime}|x) \) is obtained fromthis function computespdf(x,x_prime)
h(x,x_prime) = log_pdf(x_prime,x)-log_pdf(x,x_prime);
To check this, in the limit that \( g(x|x^{\prime}) \rightarrow P(x) \) this function returns
\[ \log \left[ \frac{P(x)}{P(x^{\prime})} \right] \]
-
size_t