#include <iostream>
#include "mcmc++/Density.h"
#include "mcmc++/MCMC.h"
#include "mcmc++/intervals.h"
Include dependency graph for MCMC.cpp:

Go to the source code of this file.
Classes | |
| struct | BadValue |
| struct | BadCT |
Defines | |
| #define | argCheck_ 1 |
| #define | checkValue_(x) ; |
Typedefs | |
| typedef ParameterT< double > | dPar |
| typedef ParameterT< int > | iPar |
| typedef ParameterT< std::vector< double > > | dVecPar |
| typedef ParameterT< std::vector< int > > | iVecPar |
| typedef ParameterT< boost::any > | aPar |
| typedef const ParameterT< double > | cdPar |
| typedef const ParameterT< int > | ciPar |
| typedef const ParameterT< std::vector< double > > | cdVecPar |
| typedef const ParameterT< std::vector< int > > | ciVecPar |
| typedef const ParameterT< boost::any > | caPar |
Functions | |
| lot & | GetRNG (void) |
| double | safeFreq (const double p, const double zero) |
| double | invSafeFreq (const double x, const double zero) |
| std::vector< double > | safeFreq (const std::vector< double > &p, const double zero) |
| std::vector< double > | invSafeFreq (const std::vector< double > &x, const double zero) |
| double | proposeBeta (const double mean, const double denom, const double tolerance) |
| double | logQBeta (const double newMean, const double oldMean, const double denom, const double tolerance) |
| std::vector< double > | proposeDirch (const std::vector< double > &q, const double denom, const double tolerance) |
| double | logQDirch (const std::vector< double > &newMean, const std::vector< double > &oldMean, const double denom, const double tolerance) |
| double | proposeNorm (const double mean, const double variance) |
| double | logQNorm (const double newMean, const double oldMean, const double variance) |
| double | safeBetaPar (const double x) |
| void | safeDirchPar (std::vector< double > &x) |
Variables | |
| const double | MCMC_ZERO_FREQ = 1.00e-14 |
The Parameter, Step, and Model classes defined here are the core classes that do all of the work. To implement a Bayesian model using these classes each parameter in the model should be derived from Paramater and should override llike(), at a minimum. lprior() should be overridden for anything other than a flat prior. (Notice that the prior will be improper unless overriden when the parameter has an unbounded domain.) The model is derived from Model, and each parameter is pushed onto a stack (step_), with a specified Step type (MetroStep, SliceStep, or FunctionStep).
Definition in file MCMC.cpp.
| #define argCheck_ 1 |
| #define checkValue_ | ( | x | ) | ; |
| typedef ParameterT<boost::any> aPar |
| typedef const ParameterT<boost::any> caPar |
| typedef const ParameterT<double> cdPar |
| typedef const ParameterT<std::vector<double> > cdVecPar |
| typedef const ParameterT<int> ciPar |
| typedef const ParameterT<std::vector<int> > ciVecPar |
| typedef ParameterT<double> dPar |
| typedef ParameterT<std::vector<double> > dVecPar |
| typedef ParameterT<int> iPar |
| typedef ParameterT<std::vector<int> > iVecPar |
| lot& GetRNG | ( | void | ) |
| std::vector<double> invSafeFreq | ( | const std::vector< double > & | x, | |
| const double | zero | |||
| ) |
Inverts a safeFreq()ed vector
| x | The vector to invert | |
| zero | The original guard (not checked) |
| double invSafeFreq | ( | const double | x, | |
| const double | zero | |||
| ) |
Converts a safeFreq()ed x back
| x | Frequency to convert back | |
| zero | Value used in original guard (not verified) |
| double logQBeta | ( | const double | newMean, | |
| const double | oldMean, | |||
| const double | denom, | |||
| const double | tolerance | |||
| ) |
lQ for a beta proposal
| newMean | New value proposed | |
| oldMean | Old value from which proposed | |
| denom | Effective sample size | |
| tolerance | Minimum value allowed in original proposal |
Definition at line 196 of file MCMC.cpp.
References Density::dbeta(), invSafeFreq(), safeBetaPar(), and Util::safeLog().
| double logQDirch | ( | const std::vector< double > & | newMean, | |
| const std::vector< double > & | oldMean, | |||
| const double | denom, | |||
| const double | tolerance | |||
| ) |
lQ for a Dirichlet proposal
| newMean | New value proposed | |
| oldMean | Old value from which proposed | |
| denom | Effective sample size | |
| tolerance | Minimum value allowed in original proposal |
Definition at line 242 of file MCMC.cpp.
References Density::ddirch(), invSafeFreq(), and Util::safeLog().
| double logQNorm | ( | const double | newMean, | |
| const double | oldMean, | |||
| const double | variance | |||
| ) |
lQ for a normal proposal
| newMean | New value proposed | |
| oldMean | Old value from which proposed | |
| variance | Variance of the proposal distribution |
Definition at line 271 of file MCMC.cpp.
References Density::dnorm(), and Util::safeLog().
| double proposeBeta | ( | const double | mean, | |
| const double | denom, | |||
| const double | tolerance | |||
| ) |
Propose a new beta variate for an M-H step
| mean | Mean for beta distribution | |
| denom | Effective sample size | |
| tolerance | Minimum value allowed (to avoid exact 0s and 1s) |
where alpha and beta are guarded by safeBetaPar()
Definition at line 178 of file MCMC.cpp.
References lot::beta(), safeBetaPar(), and safeFreq().
| std::vector<double> proposeDirch | ( | const std::vector< double > & | q, | |
| const double | denom, | |||
| const double | tolerance | |||
| ) |
Propose a new Dirichlet vector for an M-H step
| q | Mean of the proposal distribution | |
| denom | Effective sample size | |
| tolerance | Minimum value allowed (to avoid exact 0s and 1s) |
where alpha and beta are guarded by safeBetaPar()
Definition at line 220 of file MCMC.cpp.
References lot::dirichlet(), safeDirchPar(), and safeFreq().
| double proposeNorm | ( | const double | mean, | |
| const double | variance | |||
| ) |
Propose a new normal variate for an M-H step
| mean | Mean of the proposal distribution | |
| variance | Variance of the proposal distribution |
Definition at line 261 of file MCMC.cpp.
References lot::norm().
| double safeBetaPar | ( | const double | x | ) |
Ensures MinBetaPar <= x <= MaxBetaPar
| x | Frequency to guard |
Definition at line 282 of file MCMC.cpp.
References MCMC::MaxBetaPar, and MCMC::MinBetaPar.
Referenced by logQBeta(), and proposeBeta().
| void safeDirchPar | ( | std::vector< double > & | x | ) |
Ensures MinBetaPar <= x <= MaxBetaPar for all elements of a Dirichlet parameter vector
| x | Frequency to guard |
Definition at line 293 of file MCMC.cpp.
References MCMC::MaxDirchPar, and MCMC::MinDirchPar.
Referenced by proposeDirch().
| std::vector<double> safeFreq | ( | const std::vector< double > & | p, | |
| const double | zero | |||
| ) |
| double safeFreq | ( | const double | p, | |
| const double | zero | |||
| ) |
| const double MCMC_ZERO_FREQ = 1.00e-14 |
default "zero" value for safeFreq()
1.5.1