25 #include <queso/Environment.h>
26 #include <queso/math_macros.h>
27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
29 #include <queso/Algorithm.h>
30 #include <queso/TKGroup.h>
31 #include <queso/InvLogitGaussianJointPdf.h>
35 template <
class V,
class M>
44 template <
class V,
class M>
49 template <
class V,
class M>
57 double alphaQuotient = 0.;
63 std::cerr <<
"WARNING In Algorithm<V,M>::alpha(x,y)"
64 <<
", worldRank " << m_env.worldRank()
65 <<
", fullRank " << m_env.fullRank()
66 <<
", subEnvironment " << m_env.subId()
67 <<
", subRank " << m_env.subRank()
68 <<
", inter0Rank " << m_env.inter0Rank()
77 std::cerr <<
"WARNING In Algorithm<V,M>::alpha(x,y)"
78 <<
", worldRank " << m_env.worldRank()
79 <<
", fullRank " << m_env.fullRank()
80 <<
", subEnvironment " << m_env.subId()
81 <<
", subRank " << m_env.subRank()
82 <<
", inter0Rank " << m_env.inter0Rank()
91 if (m_tk.symmetric()) {
92 alphaQuotient = std::exp(yLogTargetToUse - x.
logTarget());
94 if ((m_env.subDisplayFile() ) &&
95 (m_env.displayVerbosity() >= 3 )) {
96 *m_env.subDisplayFile() <<
"In Algorithm<V,M>::alpha(x,y)"
97 <<
": symmetric proposal case"
100 <<
", yLogTargetToUse = " << yLogTargetToUse
102 <<
", alpha = " << alphaQuotient
107 double qyx = m_tk.rv(tk_pos_x).pdf().lnValue(x.
vecValues());
108 if ((m_env.subDisplayFile() ) &&
109 (m_env.displayVerbosity() >= 10 )) {
110 *m_env.subDisplayFile() << m_tk.rv(tk_pos_x).pdf() << std::endl;
112 double qxy = m_tk.rv(tk_pos_y).pdf().lnValue(y.
vecValues());
113 if ((m_env.subDisplayFile() ) &&
114 (m_env.displayVerbosity() >= 10 )) {
115 *m_env.subDisplayFile() << m_tk.rv(tk_pos_y).pdf() << std::endl;
117 alphaQuotient = std::exp(yLogTargetToUse +
121 if ((m_env.subDisplayFile() ) &&
122 (m_env.displayVerbosity() >= 3 )) {
123 *m_env.subDisplayFile() <<
"In Algorithm<V,M>::alpha(x,y)"
124 <<
": asymmetric proposal case"
127 <<
", yLogTargetToUse = " << yLogTargetToUse
128 <<
", q(y,x) = " << qyx
130 <<
", q(x,y) = " << qxy
131 <<
", alpha = " << alphaQuotient
138 if ((m_env.subDisplayFile() ) &&
139 (m_env.displayVerbosity() >= 10 )) {
140 *m_env.subDisplayFile() <<
"In Algorithm<V,M>::alpha(x,y)"
147 return std::min(1.,alphaQuotient);
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
double acceptance_ratio(MarkovChainPositionData< V > x, MarkovChainPositionData< V > y, const V &tk_pos_x, const V &tk_pos_y)
Calculates the finite dimensional Metropolis-Hastings acceptance ratio.
const V & vecValues() const
Values of the chain (vector); access to private attribute m_vecValues.
Algorithm(const BaseEnvironment &env, const BaseTKGroup< V, M > &tk)
double logTarget() const
Logarithm of the value of the target; access to private attribute m_logTarget.
This base class allows the representation of a transition kernel.
A templated class that represents a Markov Chain.
bool outOfTargetSupport() const
Whether or not a position is out of target support; access to private attribute m_outOfTargetSupport...