20 #ifndef SAMPLE_PROPOSER_H_INCLUDED
21 #define SAMPLE_PROPOSER_H_INCLUDED
55 template<
typename ConditionalDistribution,
typename Model>
80 ConditionalDistribution cd;
95 template<
typename Model>
116 m_proposers(proposers),
117 m_dist(0, proposers.size() - 1, 1)
125 m_proposers(proposers),
128 if(m_proposers.size() != m_dist.
size())
131 "distribution and proposer vector must have same size.");
145 bool keep_going =
true;
186 template<
typename Model>
206 mutable int last_modified_dim;
216 const Get_param& get_param = get_vector_model_parameter<Model>,
217 const Set_param& set_param = set_vector_model_parameter<Model>,
218 const Dimension& model_dimension = get_vector_model_dimension<Model>
220 m_proposers(proposers),
221 m_dist(0, proposers.size() - 1, 1),
224 m_dim(model_dimension),
225 last_modified_dim(-1)
236 const Get_param& get_param = get_vector_model_parameter<Model>,
237 const Set_param& set_param = set_vector_model_parameter<Model>,
238 const Dimension& model_dimension = get_vector_model_dimension<Model>
240 m_proposers(proposers),
244 m_dim(model_dimension),
245 last_modified_dim(-1)
247 if(m_proposers.size() != 1 && m_proposers.size() != m_dist.
size())
250 "Single_dimension_proposer: distribution and proposer vector "
251 "must have same size.");
263 int num_prop = m_proposers.size();
270 "Single_dimension_proposer: model dimension must be "
271 "equal to number of proposers.");
276 if(D != m_dist.
size())
279 "Single_dimension_proposer: model dimension and "
280 "distribution size must be equal.");
286 int k = (D == num_prop) ? j : 0;
289 double m_j = get_p(m, j);
292 set_p(m_p, j, m_p_j);
297 last_modified_dim = j;
306 "Single dimension proposer: cannot get latest modified dimension; "
307 "proposer has not been called yet.");
309 return last_modified_dim;
Distribution_traits< Target >::type conditional_sample(const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Given >::type &y)
Produces a sample from the given conditioanl distro, given a value for the given variable.
Definition: prob_conditional_distribution.h:135
Conditional_distribution_proposer(const ConditionalDistribution &cond_dist)
Definition: sample_proposer.h:61
double fwd_prob
log forward proposal probability
Definition: sample_base.h:379
Definition of various standard probability distributions.
Mh_proposal_result operator()(const Model &m, Model &m_p) const
Proposes new model.
Definition: sample_proposer.h:260
Indicates the result of an MH proposal. It is simply a pair of probabilities, forward and backward...
Definition: sample_base.h:334
Multi_proposer_proposer(const Proposer_vector &proposers, const kjb::Categorical_distribution< int > &dist)
Constructs a Multi_proposer_proposer with the given proposers and their distribution.
Definition: sample_proposer.h:124
for k
Definition: APPgetLargeConnectedEdges.m:61
Definition: sample_proposer.h:320
Get_model_parameter< Model >::Type Get_param
Definition: sample_proposer.h:194
double pdf(const MV_gaussian_distribution &P, const Vector &x)
Computes the joint PDF of a multivariate Gaussian at x.
Definition: prob_pdf.cpp:32
bool no_change
proposal didn't modify the model
Definition: sample_base.h:386
double rev_prob
log reverse proposal probability
Definition: sample_base.h:381
Vector sample(const MV_gaussian_distribution &dist)
Sample from a multivariate normal distribution.
Definition: prob_sample.cpp:42
double conditional_log_pdf(const Conditional_distribution< Target, Given, Func > &cd, const typename Distribution_traits< Target >::type &x, const typename Distribution_traits< Given >::type &y)
Gets the conditional log-pdf log p(x | y) of the given ConditionalDistribution.
Definition: prob_conditional_distribution.h:120
size_t size() const
Size of this distribution.
Definition: prob_distribution.h:316
Single_dimension_proposer(const Proposer_vector &proposers, const Get_param &get_param=get_vector_model_parameter< Model >, const Set_param &set_param=set_vector_model_parameter< Model >, const Dimension &model_dimension=get_vector_model_dimension< Model >)
Constructs a Single_dimension_proposer with a uniform distribution.
Definition: sample_proposer.h:214
int get_last_modified_dimension() const
Returns the most recently changed dimension of the model.
Definition: sample_proposer.h:303
std::vector< Proposer > Proposer_vector
Definition: sample_proposer.h:198
BOOST_CONCEPT_ASSERT((BaseModel< Model >))
#define IFT(a, ex, msg)
Definition: l_exception.h:101
double dist(const pt a, const pt b)
compute approx. Great Circle distance between two UTM points
Definition: layer.cpp:45
Definition: sample_proposer.h:56
PDFs and CDFs for the different distributions defined in "prob_distribution.h".
double log_pdf(const MV_gaussian_distribution &P, const Vector &x)
Computes the log PDF a multivariate normal distribution at x.
Definition: prob_pdf.cpp:64
boost::function3< void, Model &, size_t, double > Type
Definition: sample_base.h:282
boost::function2< Mh_proposal_result, const Model &, Model & > Type
Definition: sample_base.h:406
Definition of various conditional distibutions.
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
Set_model_parameter< Model >::Type Set_param
Definition: sample_proposer.h:195
Exception often thrown when wrapped C functions return error codes.
Definition: l_exception.h:262
Mh_proposal_result operator()(const Model &m, Model &mp) const
Proposes new model.
Definition: sample_proposer.h:70
boost::math::normal Normal_distribution
Definition: prob_distribution.h:68
Sampling functionality for the different distributions defined in "prob_distributions.h".
Definition: sample_proposer.h:187
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
std::vector< Proposer > Proposer_vector
Definition: sample_proposer.h:104
Gaussian_random_walk_proposer(double variance)
Construct a GRWP.
Definition: sample_proposer.h:327
for m
Definition: APPgetLargeConnectedEdges.m:64
D
Definition: APPgetLargeConnectedEdges.m:106
Support for error handling exception classes in libKJB.
Mh_proposal_result operator()(const double &m, double &mp) const
Propose a new value.
Definition: sample_proposer.h:330
boost::function2< double, const Model &, size_t > Type
Definition: sample_base.h:270
Definition: sample_concept.h:41
Definition: sample_proposer.h:96
boost::function1< size_t, const Model & > Type
Definition: sample_base.h:305
Multi_proposer_proposer(const Proposer_vector &proposers)
Constructs a Multi_proposer_proposer with a uniform distribution.
Definition: sample_proposer.h:115
Mh_proposal_result operator()(const Model &m, Model &m_p)
Proposes new model.
Definition: sample_proposer.h:140
Mh_model_proposer< double >::Type Proposer
Definition: sample_proposer.h:193
Model_dimension< Model >::Type Dimension
Definition: sample_proposer.h:196