|
CMP++: Uncertainty Quantification & Bayesian Calibration
|
Implements an Evolutionary Markov Chain Monte Carlo sampler. More...
#include <mcmc.h>
Public Member Functions | |
| EvolutionaryMarkovChain ()=default | |
| EvolutionaryMarkovChain (std::vector< Eigen::VectorXd > initialSamples, std::vector< double > initialScores, double nugget=1e-6) | |
| Constructs an EvolutionaryMarkovChain sampler. | |
| void | step (const score_t &getScore, std::default_random_engine &rng, double gamma=0.2) |
| Performs one crossover and mutation step for all chains. | |
| std::vector< Eigen::VectorXd > | getCurrent () const |
| Gets the current states of all chains. | |
| std::vector< double > | getScores () const |
| Gets the current log probability scores of all chains. | |
Protected Attributes | |
| size_t | nChains_ {0} |
| Number of active parallel chains. | |
| size_t | dim_ {0} |
| Dimension of the parameter space. | |
| std::vector< Eigen::VectorXd > | chainSamples_ |
| Current parameter samples for each chain. | |
| std::vector< double > | chainScores_ |
| Current score (log probability) for each chain. | |
| std::uniform_int_distribution< size_t > | distChain_ |
| Discrete uniform distribution helper to pick random chain. | |
| std::uniform_real_distribution< double > | distU_ {0, 1} |
| Uniform distribution helper. | |
| std::normal_distribution< double > | distN_ {0, 1} |
| Normal distribution helper. | |
| double | nugget_ {1e-6} |
| Crossover mutation noise scaling. | |
Implements an Evolutionary Markov Chain Monte Carlo sampler.
Mathematical Formulation Uses differential evolution crossover proposals. For each chain \(i\), candidate states \(\boldsymbol{\theta}_i^*\) are generated using states from two other distinct, randomly selected chains \(j\) and \(k\):
\[ \boldsymbol{\theta}_i^* = \boldsymbol{\theta}_i + \gamma (\boldsymbol{\theta}_j - \boldsymbol{\theta}_k) + \mathbf{e} \]
where \(\gamma\) is the scale factor and \(\mathbf{e} \sim \mathcal{N}(\mathbf{0}, \sigma_e^2 \mathbf{I})\) represents small mutation noise. The candidate state is accepted according to the Metropolis-Hastings probability:
\[ \alpha = \min\left(1, \exp\left(\log \pi(\boldsymbol{\theta}_i^*) - \log \pi(\boldsymbol{\theta}_i)\right)\right) \]
Implementation Algorithm
|
default |
| cmp::mcmc::EvolutionaryMarkovChain::EvolutionaryMarkovChain | ( | std::vector< Eigen::VectorXd > | initialSamples, |
| std::vector< double > | initialScores, | ||
| double | nugget = 1e-6 |
||
| ) |
Constructs an EvolutionaryMarkovChain sampler.
| initialSamples | Initial parameter states for each chain. |
| initialScores | Initial log probability scores for each chain. |
| nugget | Standard deviation scaling for crossover mutation noise. |
|
inline |
Gets the current states of all chains.
|
inline |
Gets the current log probability scores of all chains.
| void cmp::mcmc::EvolutionaryMarkovChain::step | ( | const score_t & | getScore, |
| std::default_random_engine & | rng, | ||
| double | gamma = 0.2 |
||
| ) |
Performs one crossover and mutation step for all chains.
| getScore | The log posterior probability evaluator. |
| rng | Random number engine. |
| gamma | Scale factor for difference vector in differential evolution. |
|
protected |
Current parameter samples for each chain.
|
protected |
Current score (log probability) for each chain.
|
protected |
Dimension of the parameter space.
|
protected |
Discrete uniform distribution helper to pick random chain.
|
protected |
Normal distribution helper.
|
protected |
Uniform distribution helper.
|
protected |
Number of active parallel chains.
|
protected |
Crossover mutation noise scaling.