|
UQTk: Uncertainty Quantification Toolkit 3.1.5
|
Markov Chain Monte Carlo base class. Implemented the basic and most general MCMC algorithms. More...
#include <mcmc.h>
Classes | |
| struct | chainstate |
| struct | outputInfo |
Public Member Functions | |
| MCMC (double(*logposterior)(Array1D< double > &, void *), void *postinfo) | |
| Constructor when given a pointer to a logPosterior function and a pointer to additional information (e.g. data) | |
| MCMC (LogPosteriorBase &L) | |
| Constructor when given a LogPosterior Base class object. | |
| MCMC () | |
| Dummy Constructor, used for TMCMC. | |
| void | setWriteFlag (int I) |
| Set the write flag function given an integer. | |
| void | setFcnAccept (void(*fcnAccept)(void *)) |
| Set the accept and reject functions. | |
| void | setFcnReject (void(*fcnReject)(void *)) |
| void | setChainDim (int chdim) |
| Set the dimensions of the chain given an integer. | |
| void | initChainPropCov (Array2D< double > &propcov) |
| Initialize proposal covariance matrix given as a 2d-array For aMCMC, this matrix is used only before adaptivity starts. | |
| void | initChainPropCovDiag (Array1D< double > &sig) |
| Initialize proposal covariance matrix given its 1d-array diagonal For aMCMC, this matrix is used only before adaptivity starts. | |
| void | setOutputInfo (string outtype, string file, int freq_file, int freq_screen) |
| Set output specification struct, type('txt' or 'bin'), filename, frequency of outputs to the file and to screen. | |
| void | namesPrepended () |
| Set the indicator to confirm that the names of parameters are prepended in the output file. | |
| void | setSeed (int seed) |
| Set random generation seed. | |
| void | setLower (double lower, int i) |
| Set lower bound at the index of i. | |
| void | setUpper (double upper, int i) |
| Set upper bound at the index of i. | |
| void | setDefaultDomain () |
| Set default unbounded domain. | |
| void | setPostInfo (void *postinfo) |
| Set the Posterior Info pointer. | |
| void | getChainPropCov (Array2D< double > &propcov) |
| Returns proposal covariance matrix. | |
| string | getFilename () |
| Get the name of the chain file. | |
| int | getWriteFlag () |
| Get the value of the write flag as an integer. | |
| void | getSamples (int burnin, int every, Array2D< double > &samples) |
| Get samples of the chain with burnin and thining. | |
| void | getSamples (Array2D< double > &samples) |
| Get all samples of the chain. | |
| void | getFcnAccept (void(*fcnAccept)(void *)) |
| Get the accept and reject functions given a pointer. | |
| void | getFcnReject (void(*fcnReject)(void *)) |
| string | getOutputType () |
| Get the output file type as a string. | |
| int | getFileFreq () |
| Get the frequency of output to file. | |
| int | getScreenFreq () |
| Get the frequency of output to the screen. | |
| bool | getNamesPrepended () |
| Get if the names are prepended. | |
| int | getSeed () |
| Get the seed used for random generation. | |
| double | getLower (int i) |
| Get the lower bounds based on an index i. | |
| double | getUpper (int i) |
| Get the upper bounds based on an index i. | |
| bool | getDimInit () |
| Get if the Chain Dimensions are initialized. | |
| void | getPostInfo (void *post) |
| Get post info pointer. | |
| bool | getPropCovInit () |
| Get if the Prop Cov has been initialized. | |
| bool | getOutputInit () |
| Get if the output info has been initialized. | |
| int | getLastWrite () |
| Get last write. | |
| bool | getFcnAcceptInit () |
| Get if the accept and reject functions are initialized. | |
| bool | getFcnRejectInit () |
| virtual int | getNSubSteps () |
| Get function for number of sub steps. | |
| int | getLowerFlag (int i) |
| Get function for the lower and upper Flag at index i. | |
| int | getUpperFlag (int i) |
| void | getAcceptRatio (double *accrat) |
| Get the chain's acceptance ratio. | |
| double | getAcceptRatio () |
| Get the chain's acceptance ratio as a double. | |
| int | GetChainDim () const |
| Get the MCMC chain dimensionality. | |
| void | resetChainState () |
| Reset the chain state. | |
| void | resetChainFilename (string filename) |
| Reset to a new chain file. | |
| void | parseBinChain (string filename, Array1D< chainstate > &readchain) |
| An auxiliary function to parse the binary file and produce an array of chain-states. | |
| void | writeFullChainTxt (string filename, Array1D< chainstate > fullchain) |
| Write an array of chain-states to a file. | |
| void | getFullChain (Array1D< chainstate > &readchain) |
| Get full chain as an array of chain-states. | |
| void | appendMAP () |
| Append MAP state to the end. | |
| double | getMode (Array1D< double > &MAPparams) |
| Get MAP parameters. | |
| int | getFullChainSize () |
| Get the full chain size. | |
| void | setCurrentStateStep (int i) |
| Function to set the step of the current state. | |
| void | getCurrentStateState (Array1D< double > &state) |
| Function to get the state of the current state. | |
| double | getCurrentStatePost () |
| Function to get the post of the current state. | |
| void | setCurrentStateState (Array1D< double > &newState) |
| Function to set the current state's state. | |
| void | setCurrentStatePost (double newPost) |
| Function to set the current state's post. | |
| void | setCurrentStateAlfa (double newAlfa) |
| Function to set the current state's alfa. | |
| double | getModeStatePost () |
| Function to get the mode state's post. | |
| void | getModeStateState (Array1D< double > &state) |
| Function to get the mode state's state. | |
| virtual void | runOptim (Array1D< double > &start) |
| The optimization routine. | |
| virtual void | runChain (int ncalls, Array1D< double > &chstart)=0 |
| The actual function that generates MCMC. | |
| virtual void | runChain (int ncalls)=0 |
| Start an MCMC chain with trivial initial condition. | |
| void | runAcceptFcn () |
| Function to run the accept function. | |
| void | runRejectFcn () |
| Function to run the reject function. | |
| bool | newModeFound () |
| Check to see if a new mode was found during last call to runChain. | |
| double | evalLogPosterior (Array1D< double > &m) |
| Function to evaluate the log-posterior. | |
| bool | inDomain (Array1D< double > &m) |
| Check if a point is in the domain. | |
| void | writeChainTxt (string filename) |
| Write the full chain as a text. | |
| void | writeChainBin (string filename) |
| Write the full chain as a binary file. | |
| void | setNewMode (bool value) |
| Function to set a new mode value. | |
Protected Member Functions | |
| void | setAcceptRatio (double d) |
| Set the acceptance ratio. | |
| void | addCurrentState () |
| Function to add the current chain state to the full chain. | |
| void | updateMode () |
| Function to update the Chain mode. | |
| void | setLastWrite (int i) |
| Set last write. | |
Protected Attributes | |
| dsfmt_t | RandomState |
Private Member Functions | |
| virtual double | probOldNew (Array1D< double > &a, Array1D< double > &b) |
Private Attributes | |
| int | WRITE_FLAG |
| int | FLAG |
| LogPosteriorBase * | L_ |
| struct MCMC::outputInfo | outputinfo_ |
| int | chainDim_ |
| double(* | logPosterior_ )(Array1D< double > &, void *) = NULL |
| void(* | fcnAccept_ )(void *) = NULL |
| void(* | fcnReject_ )(void *) = NULL |
| void * | postInfo_ = NULL |
| Array2D< double > | chcov |
| int | seed_ |
| chainstate | currState_ |
| chainstate | modeState_ |
| Array1D< chainstate > | fullChain_ |
| int | lastwrite_ |
| bool | namesPrepend = false |
| bool | newMode_ = false |
| double | accRatio_ = -1.0 |
| bool | chaindimInit_ = false |
| bool | propcovInit_ = false |
| bool | methodInit_ = false |
| bool | outputInit_ = false |
| bool | fcnAcceptFlag_ = false |
| bool | fcnRejectFlag_ = false |
| Array1D< double > | Lower_ |
| Lower bounds. | |
| Array1D< double > | Upper_ |
| Upper bounds. | |
| Array1D< int > | lower_flag_ |
| Lower bound existence flags. | |
| Array1D< int > | upper_flag_ |
| Upper bound existence flags. | |
Markov Chain Monte Carlo base class. Implemented the basic and most general MCMC algorithms.
| MCMC::MCMC | ( | double(* | logposterior )(Array1D< double > &, void *), |
| void * | postinfo ) |
Constructor when given a pointer to a logPosterior function and a pointer to additional information (e.g. data)
| MCMC::MCMC | ( | LogPosteriorBase & | L | ) |
Constructor when given a LogPosterior Base class object.
| MCMC::MCMC | ( | ) |
Dummy Constructor, used for TMCMC.
|
protected |
Function to add the current chain state to the full chain.
| void MCMC::appendMAP | ( | ) |
Append MAP state to the end.
| double MCMC::evalLogPosterior | ( | Array1D< double > & | m | ) |
Function to evaluate the log-posterior.
| double MCMC::getAcceptRatio | ( | ) |
Get the chain's acceptance ratio as a double.
| void MCMC::getAcceptRatio | ( | double * | accrat | ) |
Get the chain's acceptance ratio.
| int MCMC::GetChainDim | ( | ) | const |
Get the MCMC chain dimensionality.
| void MCMC::getChainPropCov | ( | Array2D< double > & | propcov | ) |
Returns proposal covariance matrix.
| double MCMC::getCurrentStatePost | ( | ) |
Function to get the post of the current state.
| void MCMC::getCurrentStateState | ( | Array1D< double > & | state | ) |
Function to get the state of the current state.
| bool MCMC::getDimInit | ( | ) |
Get if the Chain Dimensions are initialized.
| void MCMC::getFcnAccept | ( | void(* | fcnAccept )(void *) | ) |
Get the accept and reject functions given a pointer.
| bool MCMC::getFcnAcceptInit | ( | ) |
Get if the accept and reject functions are initialized.
| void MCMC::getFcnReject | ( | void(* | fcnReject )(void *) | ) |
| bool MCMC::getFcnRejectInit | ( | ) |
| int MCMC::getFileFreq | ( | ) |
Get the frequency of output to file.
| string MCMC::getFilename | ( | ) |
Get the name of the chain file.
| void MCMC::getFullChain | ( | Array1D< chainstate > & | readchain | ) |
Get full chain as an array of chain-states.
| int MCMC::getFullChainSize | ( | ) |
Get the full chain size.
| int MCMC::getLastWrite | ( | ) |
Get last write.
| double MCMC::getLower | ( | int | i | ) |
Get the lower bounds based on an index i.
| int MCMC::getLowerFlag | ( | int | i | ) |
Get function for the lower and upper Flag at index i.
| double MCMC::getMode | ( | Array1D< double > & | MAPparams | ) |
Get MAP parameters.
| double MCMC::getModeStatePost | ( | ) |
Function to get the mode state's post.
| void MCMC::getModeStateState | ( | Array1D< double > & | state | ) |
Function to get the mode state's state.
| bool MCMC::getNamesPrepended | ( | ) |
Get if the names are prepended.
|
inlinevirtual |
Get function for number of sub steps.
| bool MCMC::getOutputInit | ( | ) |
Get if the output info has been initialized.
| string MCMC::getOutputType | ( | ) |
Get the output file type as a string.
| void MCMC::getPostInfo | ( | void * | post | ) |
Get post info pointer.
| bool MCMC::getPropCovInit | ( | ) |
Get if the Prop Cov has been initialized.
| void MCMC::getSamples | ( | Array2D< double > & | samples | ) |
Get all samples of the chain.
| void MCMC::getSamples | ( | int | burnin, |
| int | every, | ||
| Array2D< double > & | samples ) |
Get samples of the chain with burnin and thining.
| int MCMC::getScreenFreq | ( | ) |
Get the frequency of output to the screen.
| int MCMC::getSeed | ( | ) |
Get the seed used for random generation.
| double MCMC::getUpper | ( | int | i | ) |
Get the upper bounds based on an index i.
| int MCMC::getUpperFlag | ( | int | i | ) |
| int MCMC::getWriteFlag | ( | ) |
Get the value of the write flag as an integer.
| bool MCMC::inDomain | ( | Array1D< double > & | m | ) |
Check if a point is in the domain.
| void MCMC::initChainPropCov | ( | Array2D< double > & | propcov | ) |
Initialize proposal covariance matrix given as a 2d-array For aMCMC, this matrix is used only before adaptivity starts.
| void MCMC::initChainPropCovDiag | ( | Array1D< double > & | sig | ) |
Initialize proposal covariance matrix given its 1d-array diagonal For aMCMC, this matrix is used only before adaptivity starts.
| void MCMC::namesPrepended | ( | ) |
Set the indicator to confirm that the names of parameters are prepended in the output file.
| bool MCMC::newModeFound | ( | ) |
Check to see if a new mode was found during last call to runChain.
| void MCMC::parseBinChain | ( | string | filename, |
| Array1D< chainstate > & | readchain ) |
An auxiliary function to parse the binary file and produce an array of chain-states.
|
inlineprivatevirtual |
| void MCMC::resetChainFilename | ( | string | filename | ) |
Reset to a new chain file.
| void MCMC::resetChainState | ( | ) |
Reset the chain state.
| void MCMC::runAcceptFcn | ( | ) |
Function to run the accept function.
|
pure virtual |
Start an MCMC chain with trivial initial condition.
|
pure virtual |
The actual function that generates MCMC.
|
virtual |
The optimization routine.
| void MCMC::runRejectFcn | ( | ) |
Function to run the reject function.
|
protected |
Set the acceptance ratio.
| void MCMC::setChainDim | ( | int | chdim | ) |
Set the dimensions of the chain given an integer.
| void MCMC::setCurrentStateAlfa | ( | double | newAlfa | ) |
Function to set the current state's alfa.
| void MCMC::setCurrentStatePost | ( | double | newPost | ) |
Function to set the current state's post.
| void MCMC::setCurrentStateState | ( | Array1D< double > & | newState | ) |
Function to set the current state's state.
| void MCMC::setCurrentStateStep | ( | int | i | ) |
Function to set the step of the current state.
| void MCMC::setDefaultDomain | ( | ) |
Set default unbounded domain.
| void MCMC::setFcnAccept | ( | void(* | fcnAccept )(void *) | ) |
Set the accept and reject functions.
| void MCMC::setFcnReject | ( | void(* | fcnReject )(void *) | ) |
|
protected |
Set last write.
| void MCMC::setLower | ( | double | lower, |
| int | i ) |
Set lower bound at the index of i.
| void MCMC::setNewMode | ( | bool | value | ) |
Function to set a new mode value.
| void MCMC::setOutputInfo | ( | string | outtype, |
| string | file, | ||
| int | freq_file, | ||
| int | freq_screen ) |
Set output specification struct, type('txt' or 'bin'), filename, frequency of outputs to the file and to screen.
| void MCMC::setPostInfo | ( | void * | postinfo | ) |
Set the Posterior Info pointer.
| void MCMC::setSeed | ( | int | seed | ) |
Set random generation seed.
| void MCMC::setUpper | ( | double | upper, |
| int | i ) |
Set upper bound at the index of i.
| void MCMC::setWriteFlag | ( | int | I | ) |
Set the write flag function given an integer.
|
protected |
Function to update the Chain mode.
| void MCMC::writeChainBin | ( | string | filename | ) |
Write the full chain as a binary file.
| void MCMC::writeChainTxt | ( | string | filename | ) |
Write the full chain as a text.
| void MCMC::writeFullChainTxt | ( | string | filename, |
| Array1D< chainstate > | fullchain ) |
Write an array of chain-states to a file.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Lower bounds.
|
private |
Lower bound existence flags.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
Upper bounds.
|
private |
Upper bound existence flags.
|
private |