1 #ifndef HOPS_MODELMIXIN_HPP
2 #define HOPS_MODELMIXIN_HPP
16 template<
typename MarkovChainProposer,
typename ModelType>
17 class ModelMixin :
public MarkovChainProposer,
public ModelType {
19 ModelMixin(
const MarkovChainProposer &markovChainProposer,
const ModelType &model) :
20 MarkovChainProposer(markovChainProposer),
22 proposalNegativeLogLikelihood = 0;
23 stateNegativeLogLikelihood = ModelType::computeNegativeLogLikelihood(MarkovChainProposer::getState());
33 double stateNegativeLogLikelihood;
34 double proposalNegativeLogLikelihood;
37 template<
typename MarkovChainProposer,
typename ModelType>
39 MarkovChainProposer::acceptProposal();
40 stateNegativeLogLikelihood = proposalNegativeLogLikelihood;
43 template<
typename MarkovChainProposer,
typename ModelType>
45 double acceptanceProbability = 0;
47 acceptanceProbability += MarkovChainProposer::computeLogAcceptanceProbability();
49 if (std::isfinite(acceptanceProbability)) {
50 proposalNegativeLogLikelihood = ModelType::computeNegativeLogLikelihood(
51 MarkovChainProposer::getProposal());
52 acceptanceProbability += stateNegativeLogLikelihood - proposalNegativeLogLikelihood;
54 return acceptanceProbability;
57 template<
typename MarkovChainProposer,
typename ModelType>
59 return stateNegativeLogLikelihood;
63 #endif //HOPS_MODELMIXIN_HPP