Class prob_cond_mdim_fixed_step (o2scl)

O2scl : Class List

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

Conditional probability for a random walk inside a hypercube.

This conditional probability is most useful in providing a Metropolis-Hastings distribution with a fixed step size which properly handles a boundary. The Metropolis-Hastings step is accepted if \( r \in [0,1] \) obeys

\[ r < \frac{P(x^{\prime})g(x|x^{\prime})} {P(x)g(x^{\prime}|x)} \]
The function \( g(x^{\prime}|x) = g(x^{\prime},x)/g(x) \), and because of the fixed step size these probabilities are just proportional to the inverse allowed volume, i.e. \( V(x)^{-1} V^{-1}(x^{\prime}) / V(x)^{-1} = V^{-1}(x^{\prime}) \) . If \( x^{\prime} \) is near a boundary then \( V(x^{\prime}) \) is decreased and the conditional probability increases accordingly. If the distance between \( x \) and \( x^{\prime} \) is unreachable in a step, then the PDF is zero.

Note

This class is experimental.

Note

Const functions are not thread-safe because the class contains an internal mutable random number generator object.

Public Functions

inline prob_cond_mdim_fixed_step()
inline prob_cond_mdim_fixed_step(const prob_cond_mdim_fixed_step &pcmfs)

Copy constructor.

inline prob_cond_mdim_fixed_step &operator=(const prob_cond_mdim_fixed_step &pcmfs)

Copy constructor with operator=.

inline virtual ~prob_cond_mdim_fixed_step()

Virtual destructor.

inline void set_seed(unsigned long int s)

Set the random number generator seed.

template<class = vec_t>
inline prob_cond_mdim_fixed_step(vec_t &step, vec_t &low, vec_t &high)

Create a conditional probability object with specified step sizes and limits.

inline virtual int set(vec_t &step, vec_t &low, vec_t &high)

Set step sizes and limits.

inline virtual size_t dim() const

The dimensionality.

inline virtual double pdf(const vec_t &x_B, const vec_t &x_A) const

The conditional probability of x_A given x_B, i.e. \( P(A|B) \).

inline virtual double log_pdf(const vec_t &x_B, const vec_t &x_A) const

The log of the conditional probability of x_A given x_B i.e. \( \log [P(A|B)] \).

inline virtual void operator()(const vec_t &x_B, vec_t &x_A) const

Sample the distribution.

Protected Functions

inline int set_internal(size_t sz, vec_t &step, vec_t &low, vec_t &high)

Internal set function.

Protected Attributes

std::vector<double> u_step

Step sizes.

std::vector<double> u_low

Lower limits.

std::vector<double> u_high

Upper limits.

rng rg

Internal random number generator.