SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
CMCMC< T > Class Template Reference

Markov Chain Monte Carlo sampler for Bayesian parameter estimation. More...

#include <MCMC/MCMC.h>

Inheritance diagram for CMCMC< T >:
Inheritance graph
Collaboration diagram for CMCMC< T >:
Collaboration graph

Public Member Functions

 CMCMC (void)
 Default constructor.
 
 CMCMC (int nn, int nn_chains)
 Constructor with chain configuration.
 
 CMCMC (T *system)
 Constructor with model pointer.
 
bool SetProperty (const string &varname, const string &value)
 Set MCMC properties from string key-value pairs.
 
 ~CMCMC (void)
 Destructor.
 
void initialize (CMBTimeSeriesSet *results, bool random=false)
 Initialize MCMC chains with starting parameter values.
 
void initialize (vector< double > par)
 Initialize all chains with specific parameter values.
 
bool step (int k, int chain_counter)
 Perform single MCMC step for one chain.
 
bool step (int k, int nsamps, string filename, CMBTimeSeriesSet *results=nullptr, ProgressWindow *_rtw=0)
 Perform multiple MCMC steps with progress tracking and output.
 
vector< double > purturb (int k)
 Generate proposed parameter values by perturbing current state.
 
void writeoutput (string filename)
 Write MCMC results to output file.
 
double posterior (vector< double > par, int chain_counter)
 Calculate log-posterior probability for given parameters.
 
void model (T *Model1, vector< double > par)
 Evaluate model with given parameters.
 
int getparamno (int i, int ts) const
 Get parameter index for a specific variable and time series.
 
int get_act_paramno (int i)
 Get active parameter number (legacy, may be unused)
 
int get_time_series (int i)
 Get time series index for parameter (legacy, may be unused)
 
Parameterparameter (int i)
 Get pointer to specific parameter.
 
Observationobservation (int i)
 Get pointer to specific observation.
 
CVector sensitivity (double d, vector< double > par)
 Calculate sensitivity of model output to parameters.
 
CVector sensitivity_ln (double d, vector< double > par)
 Calculate log-space sensitivity (for lognormal parameters)
 
CMatrix sensitivity_mat_lumped (double d, vector< double > par)
 Calculate lumped sensitivity matrix.
 
TimeSeriesSet< double > prior_distribution (int n_bins)
 Generate histogram of prior distributions.
 
int readfromfile (string filename)
 Read MCMC state from file to continue previous run.
 
TimeSeriesSet< double > model (vector< double > par)
 Evaluate model for given parameters and return predictions.
 
void ProduceRealizations (TimeSeriesSet< double > &MCMCout)
 Generate posterior predictive realizations.
 
void get_outputpercentiles (TimeSeriesSet< double > &MCMCout)
 Calculate percentiles of model outputs from MCMC samples.
 
void SetRunTimeWindow (ProgressWindow *_rtw)
 Set progress window for GUI updates.
 
void Perform ()
 Main entry point to run complete MCMC analysis.
 

Public Attributes

T * Model
 Pointer to the model object being calibrated.
 
Model_out
 Output model state after MCMC completion.
 
_MCMC_settings MCMC_Settings
 MCMC algorithm configuration settings.
 
vector< vector< double > > Params
 Parameter values for all samples and chains.
 
vector< double > pertcoeff
 Perturbation coefficients for each parameter.
 
vector< double > logp
 Log-posterior values for current state of each chain.
 
vector< double > logp1
 Log-posterior values for proposed states.
 
vector< double > u
 Uniform random values for Metropolis-Hastings accept/reject.
 
vector< CVector > temp_predicted
 Temporary storage for predicted model outputs.
 
CMBTimeSeriesSet predicted
 Model predictions as time series set.
 
vector< T > CopiedModels
 Copies of model object for parallel chain evaluation.
 
vector< int > params
 Parameter indices for model evaluation.
 
TimeSeriesSet< double > MData
 Measured data (observations) for likelihood calculation.
 
_MCMC_file_names FileInformation
 File paths for MCMC input/output.
 
vector< bool > apply_to_all
 Flags indicating if parameter applies to all entities.
 
vector< Parameter > * parameters = nullptr
 Pointer to vector of Parameter objects.
 
vector< Observation > * observations = nullptr
 Pointer to vector of Observation objects.
 
ProgressWindowrtw = nullptr
 Pointer to progress window for GUI updates.
 
vector< vector< TimeSeriesSet< double > > > BTCout_obs
 Posterior predictive samples for observations.
 
vector< vector< TimeSeriesSet< double > > > BTCout_obs_noise
 Posterior predictive samples with simulated measurement noise.
 
vector< vector< TimeSeriesSet< double > > > BTCout_obs_prcntle
 Percentiles of posterior predictive distribution.
 
vector< vector< TimeSeriesSet< double > > > BTCout_obs_prcntle_noise
 Percentiles of posterior predictive distribution with noise.
 
vector< CMatrix > global_sens_lumped
 Global sensitivity analysis results (lumped)
 
TimeSeriesSet< double > paramsList
 List of all parameter samples from MCMC.
 
TimeSeriesSet< double > realized_paramsList
 Parameter samples for posterior predictive realizations.
 
vector< double > calc_output_percentiles
 Percentiles to calculate for output distributions.
 
double accepted_count = 0
 Count of accepted proposals.
 
double total_count = 0
 Count of total proposals (accepted + rejected)
 
string last_error
 Last error message from MCMC execution.
 

Private Member Functions

int_value_pair Min (const vector< double > &vec, int current_counter, int n_chains)
 Find minimum value and its chain index.
 
int_value_pair Max (const vector< double > &vec, int current_counter, int n_chains)
 Find maximum value and its chain index.
 

Detailed Description

template<class T>
class CMCMC< T >

Markov Chain Monte Carlo sampler for Bayesian parameter estimation.

The CMCMC class implements a sophisticated Metropolis-Hastings MCMC algorithm with advanced features for Bayesian inference in sediment source fingerprinting.

Algorithm Overview

MCMC generates samples from the posterior distribution p(θ|data) ∝ p(data|θ) × p(θ) using a random walk with accept/reject steps:

  1. Propose: Generate candidate θ* from proposal distribution q(θ*|θ_current)
  2. Evaluate: Calculate posterior ratio R = p(θ*|data) / p(θ_current|data)
  3. Accept/Reject: Accept θ* with probability min(1, R), else keep θ_current
  4. Repeat: Continue until desired number of samples obtained

Key Features

  • Multiple parallel chains for convergence diagnostics
  • Adaptive proposal tuning to achieve target acceptance rate
  • Sensitivity-based proposals for efficient exploration
  • Posterior predictive sampling for uncertainty quantification
  • Progress tracking with GUI integration
  • Checkpoint/resume capability for long runs

Usage in SedSat3

MCMC provides fully Bayesian estimates of source contributions with uncertainty:

  • Mean contributions from posterior means
  • Credible intervals (e.g., 95% intervals) from percentiles
  • Correlation between source contributions
  • Posterior predictive distributions for tracer concentrations

Mathematical Details

Log-posterior calculation:

log p(θ|data) = log p(data|θ) + log p(θ) + constant
= Σ log N(y_i | model(θ)_i, σ_i²) + Σ log p(θ_j)
void model(T *Model1, vector< double > par)
Evaluate model with given parameters.
Definition MCMC.hpp:182

Where:

  • y_i are observed tracer concentrations
  • model(θ)_i are predicted concentrations from mixing model
  • σ_i are measurement uncertainties
  • p(θ_j) are parameter prior distributions
Template Parameters
TModel class type (e.g., SourceSinkData) that provides:
  • Parameter evaluation interface
  • Likelihood calculation
  • Model predictions
Note
Thread-safe: Multiple chains can run in parallel
Warning
Requires careful tuning of proposal distribution for efficiency
See also
Parameter
Observation
SourceSinkData

Example usage:

// Create MCMC sampler for source apportionment
CMCMC<SourceSinkData> mcmc(&sourceData);
// Configure settings
mcmc.MCMC_Settings.total_number_of_samples = 50000;
mcmc.MCMC_Settings.number_of_chains = 4;
mcmc.MCMC_Settings.burnout_samples = 10000;
mcmc.MCMC_Settings.acceptance_rate = 0.234;
// Set parameters and observations
mcmc.parameters = &sourceParameters;
mcmc.observations = &tracerObservations;
// Run MCMC
mcmc.Perform();
// Extract results
mcmc.writeoutput("mcmc_results.txt");
mcmc.get_outputpercentiles(results); // Get credible intervals
Markov Chain Monte Carlo sampler for Bayesian parameter estimation.
Definition MCMC.h:326

Definition at line 325 of file MCMC.h.

Constructor & Destructor Documentation

◆ CMCMC() [1/3]

template<class T >
CMCMC< T >::CMCMC ( void  )

Default constructor.

Creates an uninitialized MCMC object. Must call other initialization methods before running.

Definition at line 19 of file MCMC.hpp.

◆ CMCMC() [2/3]

template<class T >
CMCMC< T >::CMCMC ( int  nn,
int  nn_chains 
)

Constructor with chain configuration.

Parameters
nnNumber of parameters
nn_chainsNumber of parallel chains

Initializes MCMC with specified dimensions and chain count.

◆ CMCMC() [3/3]

template<class T >
CMCMC< T >::CMCMC ( T *  system)

Constructor with model pointer.

Parameters
systemPointer to model object to be calibrated

Preferred constructor that links MCMC to a specific model instance.

Definition at line 536 of file MCMC.hpp.

◆ ~CMCMC()

template<class T >
CMCMC< T >::~CMCMC ( void  )

Destructor.

Cleans up allocated memory and closes output files.

Definition at line 24 of file MCMC.hpp.

Member Function Documentation

◆ get_act_paramno()

template<class T >
int CMCMC< T >::get_act_paramno ( int  i)

Get active parameter number (legacy, may be unused)

Parameters
iParameter index
Returns
Active parameter number

◆ get_outputpercentiles()

template<class T >
void CMCMC< T >::get_outputpercentiles ( TimeSeriesSet< double > &  MCMCout)

Calculate percentiles of model outputs from MCMC samples.

Parameters
MCMCoutTimeSeriesSet containing MCMC samples

Computes credible intervals (percentiles specified in calc_output_percentiles) for all model outputs, providing uncertainty bounds on predictions.

Definition at line 696 of file MCMC.hpp.

◆ get_time_series()

template<class T >
int CMCMC< T >::get_time_series ( int  i)

Get time series index for parameter (legacy, may be unused)

Parameters
iParameter index
Returns
Time series index

◆ getparamno()

template<class T >
int CMCMC< T >::getparamno ( int  i,
int  ts 
) const

Get parameter index for a specific variable and time series.

Parameters
iVariable index
tsTime series index
Returns
Parameter index in MCMC parameter vector

◆ initialize() [1/2]

template<class T >
void CMCMC< T >::initialize ( CMBTimeSeriesSet results,
bool  random = false 
)

Initialize MCMC chains with starting parameter values.

Parameters
resultsPointer to results structure to store output (optional)
randomIf true, randomize initial values within parameter ranges

Sets up chains at initial parameter values. If random=true and noinipurt=false, adds random perturbations to explore different starting regions.

Precondition
parameters and observations must be set
Postcondition
Chains are positioned at starting values

Definition at line 200 of file MCMC.hpp.

References high, log, and low.

Referenced by Conductor::ExecuteTestCMBBayesian(), and SourceSinkData::MCMC().

◆ initialize() [2/2]

template<class T >
void CMCMC< T >::initialize ( vector< double >  par)

Initialize all chains with specific parameter values.

Parameters
parVector of parameter values [p1, p2, ..., pn]

All chains start at the same parameter values (may be perturbed if noinipurt=false).

Definition at line 278 of file MCMC.hpp.

References high, log, and low.

◆ Max()

template<class T >
int_value_pair CMCMC< T >::Max ( const vector< double > &  vec,
int  current_counter,
int  n_chains 
)
private

Find maximum value and its chain index.

Parameters
vecVector of values (one per chain)
current_counterCurrent sample number
n_chainsNumber of chains
Returns
Pair containing chain index and maximum value

Utility for tracking worst (lowest likelihood) chain.

Definition at line 787 of file MCMC.hpp.

◆ Min()

template<class T >
int_value_pair CMCMC< T >::Min ( const vector< double > &  vec,
int  current_counter,
int  n_chains 
)
private

Find minimum value and its chain index.

Parameters
vecVector of values (one per chain)
current_counterCurrent sample number
n_chainsNumber of chains
Returns
Pair containing chain index and minimum value

Utility for tracking best (highest likelihood) chain.

Definition at line 771 of file MCMC.hpp.

References int_value_pair::value.

◆ model() [1/2]

template<class T >
void CMCMC< T >::model ( T *  Model1,
vector< double >  par 
)

Evaluate model with given parameters.

Parameters
Model1Pointer to model object to evaluate
parParameter values to use

Sets parameters in model and computes predictions. Used within posterior() for likelihood calculation.

Definition at line 182 of file MCMC.hpp.

◆ model() [2/2]

template<class T >
TimeSeriesSet< double > CMCMC< T >::model ( vector< double >  par)

Evaluate model for given parameters and return predictions.

Parameters
parParameter values
Returns
TimeSeriesSet of model predictions

Wrapper for model evaluation that returns predictions in convenient format.

Definition at line 46 of file MCMC.hpp.

◆ observation()

template<class T >
Observation * CMCMC< T >::observation ( int  i)

Get pointer to specific observation.

Parameters
iObservation index
Returns
Pointer to Observation object

Definition at line 40 of file MCMC.hpp.

◆ parameter()

template<class T >
Parameter * CMCMC< T >::parameter ( int  i)

Get pointer to specific parameter.

Parameters
iParameter index
Returns
Pointer to Parameter object

Definition at line 33 of file MCMC.hpp.

◆ Perform()

template<class T >
void CMCMC< T >::Perform ( )

Main entry point to run complete MCMC analysis.

Executes full MCMC workflow:

  1. Initialize chains
  2. Run burn-in samples
  3. Run production samples
  4. Calculate statistics and diagnostics
  5. Generate posterior predictive distributions
  6. Save results to files
Precondition
parameters and observations must be set
MCMC_Settings must be configured
Postcondition
Results written to output files
paramsList contains posterior samples
See also
MCMC_Settings

Definition at line 725 of file MCMC.hpp.

◆ posterior()

template<class T >
double CMCMC< T >::posterior ( vector< double >  par,
int  chain_counter 
)

Calculate log-posterior probability for given parameters.

Parameters
parParameter vector [θ1, θ2, ..., θn]
chain_counterChain index for thread-safe model evaluation
Returns
ln(p(θ|data)) = ln(p(data|θ)) + ln(p(θ))

Computes:

  1. Log-likelihood: Σ ln N(y_observed | y_predicted(θ), σ²)
  2. Log-prior: Σ ln p(θ_i) from Parameter::CalcLogPriorProbability()
  3. Log-posterior: Sum of above
Note
Uses log-space to prevent numerical underflow
See also
Parameter::CalcLogPriorProbability()

Definition at line 164 of file MCMC.hpp.

◆ prior_distribution()

template<class T >
TimeSeriesSet< double > CMCMC< T >::prior_distribution ( int  n_bins)

Generate histogram of prior distributions.

Parameters
n_binsNumber of bins for histogram
Returns
TimeSeriesSet containing prior PDFs for each parameter

Creates visual representation of priors for plotting and comparison with posteriors.

Definition at line 610 of file MCMC.hpp.

◆ ProduceRealizations()

template<class T >
void CMCMC< T >::ProduceRealizations ( TimeSeriesSet< double > &  MCMCout)

Generate posterior predictive realizations.

Parameters
MCMCoutTimeSeriesSet containing MCMC samples

Samples parameters from posterior and evaluates model to create posterior predictive distribution for uncertainty quantification.

Number of realizations set by MCMC_Settings.number_of_post_estimate_realizations.

Definition at line 652 of file MCMC.hpp.

◆ purturb()

template<class T >
vector< double > CMCMC< T >::purturb ( int  k)

Generate proposed parameter values by perturbing current state.

Parameters
kChain index to perturb
Returns
Vector of proposed parameter values

Proposal distribution: θ* ~ N(θ_current, diag(pertcoeff²)) Respects parameter bounds by reflecting or rejecting out-of-bounds proposals.

Definition at line 377 of file MCMC.hpp.

◆ readfromfile()

template<class T >
int CMCMC< T >::readfromfile ( string  filename)

Read MCMC state from file to continue previous run.

Parameters
filenamePath to file containing saved MCMC state
Returns
Number of samples read, or negative value on error

Restores:

  • Current parameter values for each chain
  • Perturbation coefficients
  • Acceptance statistics

Allows resuming long MCMC runs without starting over.

Definition at line 584 of file MCMC.hpp.

◆ sensitivity()

template<class T >
CVector CMCMC< T >::sensitivity ( double  d,
vector< double >  par 
)

Calculate sensitivity of model output to parameters.

Parameters
dFinite difference step size (fractional)
parCurrent parameter values
Returns
Vector of sensitivities dOutput/dθ for each parameter

Computes numerical derivatives using forward finite differences: S_i = (model(θ + δθ_i) - model(θ)) / δθ_i

Used for sensitivity-based proposal adaptation.

Definition at line 554 of file MCMC.hpp.

◆ sensitivity_ln()

template<class T >
CVector CMCMC< T >::sensitivity_ln ( double  d,
vector< double >  par 
)

Calculate log-space sensitivity (for lognormal parameters)

Parameters
dFinite difference step size (fractional)
parCurrent parameter values in log-space
Returns
Vector of log-space sensitivities

Definition at line 572 of file MCMC.hpp.

◆ sensitivity_mat_lumped()

template<class T >
CMatrix CMCMC< T >::sensitivity_mat_lumped ( double  d,
vector< double >  par 
)

Calculate lumped sensitivity matrix.

Parameters
dFinite difference step size
parCurrent parameter values
Returns
Matrix of sensitivities [outputs × parameters]

Computes full Jacobian matrix of model outputs with respect to parameters. Used for global sensitivity analysis and identifiability assessment.

◆ SetProperty()

template<class T >
bool CMCMC< T >::SetProperty ( const string varname,
const string value 
)

Set MCMC properties from string key-value pairs.

Parameters
varnameProperty name (e.g., "number_of_samples", "acceptance_rate")
valueProperty value as string
Returns
true if property was recognized and set successfully

Allows configuration from text files or user input.

Definition at line 68 of file MCMC.hpp.

Referenced by Conductor::ExecuteTestCMBBayesian(), and SourceSinkData::MCMC().

◆ SetRunTimeWindow()

template<class T >
void CMCMC< T >::SetRunTimeWindow ( ProgressWindow _rtw)

Set progress window for GUI updates.

Parameters
_rtwPointer to ProgressWindow object

Links MCMC to a progress dialog for real-time status updates.

Definition at line 530 of file MCMC.hpp.

◆ step() [1/2]

template<class T >
bool CMCMC< T >::step ( int  k,
int  chain_counter 
)

Perform single MCMC step for one chain.

Parameters
kSample iteration number
chain_counterIndex of chain to advance
Returns
true if proposed state was accepted, false if rejected

Executes one Metropolis-Hastings update:

  1. Propose new parameters
  2. Calculate log-posterior
  3. Accept/reject based on Metropolis ratio
  4. Update acceptance statistics

Definition at line 337 of file MCMC.hpp.

References log.

Referenced by Conductor::ExecuteTestCMBBayesian(), and SourceSinkData::MCMC().

◆ step() [2/2]

template<class T >
bool CMCMC< T >::step ( int  k,
int  nsamps,
string  filename,
CMBTimeSeriesSet results = nullptr,
ProgressWindow _rtw = 0 
)

Perform multiple MCMC steps with progress tracking and output.

Parameters
kStarting sample number
nsampsNumber of samples to generate
filenameOutput file for saving samples
resultsPointer to results structure (optional)
_rtwPointer to progress window for GUI updates (optional)
Returns
true if completed successfully

Runs the main MCMC loop with:

  • Periodic output saving
  • Adaptive proposal tuning
  • Progress bar updates
  • Convergence monitoring
See also
ProgressWindow

Definition at line 393 of file MCMC.hpp.

◆ writeoutput()

template<class T >
void CMCMC< T >::writeoutput ( string  filename)

Write MCMC results to output file.

Parameters
filenamePath to output file

Saves:

  • Parameter samples (after burn-in)
  • Acceptance rates
  • Posterior statistics (mean, std dev, percentiles)
  • Convergence diagnostics

Format is typically tab-delimited text for easy import into analysis software.

Member Data Documentation

◆ accepted_count

template<class T >
double CMCMC< T >::accepted_count = 0

Count of accepted proposals.

Running total across all chains and samples. Used to calculate overall acceptance rate.

Definition at line 812 of file MCMC.h.

◆ apply_to_all

template<class T >
vector<bool> CMCMC< T >::apply_to_all

Flags indicating if parameter applies to all entities.

Used for shared parameters across multiple sources or observations.

Definition at line 612 of file MCMC.h.

◆ BTCout_obs

template<class T >
vector<vector<TimeSeriesSet<double> > > CMCMC< T >::BTCout_obs

Posterior predictive samples for observations.

Model predictions at sampled parameter values. Structure: BTCout_obs[observation][realization]

Definition at line 725 of file MCMC.h.

◆ BTCout_obs_noise

template<class T >
vector<vector<TimeSeriesSet<double> > > CMCMC< T >::BTCout_obs_noise

Posterior predictive samples with simulated measurement noise.

As BTCout_obs but with added observation errors sampled from measurement uncertainty distributions.

Definition at line 733 of file MCMC.h.

◆ BTCout_obs_prcntle

template<class T >
vector<vector<TimeSeriesSet<double> > > CMCMC< T >::BTCout_obs_prcntle

Percentiles of posterior predictive distribution.

Credible intervals for model predictions (e.g., 2.5%, 50%, 97.5% percentiles).

Definition at line 740 of file MCMC.h.

◆ BTCout_obs_prcntle_noise

template<class T >
vector<vector<TimeSeriesSet<double> > > CMCMC< T >::BTCout_obs_prcntle_noise

Percentiles of posterior predictive distribution with noise.

Credible intervals including measurement uncertainty.

Definition at line 747 of file MCMC.h.

◆ calc_output_percentiles

template<class T >
vector<double> CMCMC< T >::calc_output_percentiles

Percentiles to calculate for output distributions.

Vector of percentile values (0-1 scale) to compute. Typical: {0.025, 0.16, 0.5, 0.84, 0.975} for 95% and 68% intervals.

Definition at line 796 of file MCMC.h.

◆ CopiedModels

template<class T >
vector<T> CMCMC< T >::CopiedModels

Copies of model object for parallel chain evaluation.

Each chain gets its own model copy to allow thread-safe parallel execution. Dimensions: [number_of_chains]

Definition at line 520 of file MCMC.h.

◆ FileInformation

template<class T >
_MCMC_file_names CMCMC< T >::FileInformation

File paths for MCMC input/output.

Configuration structure containing output directory and filenames.

Definition at line 557 of file MCMC.h.

◆ global_sens_lumped

template<class T >
vector<CMatrix> CMCMC< T >::global_sens_lumped

Global sensitivity analysis results (lumped)

Sensitivity matrices calculated across posterior samples.

Definition at line 754 of file MCMC.h.

◆ last_error

template<class T >
string CMCMC< T >::last_error

Last error message from MCMC execution.

If MCMC fails or encounters issues, error description is stored here.

Definition at line 826 of file MCMC.h.

◆ logp

template<class T >
vector<double> CMCMC< T >::logp

Log-posterior values for current state of each chain.

Dimensions: [number_of_chains] Updated after each MCMC step.

Definition at line 415 of file MCMC.h.

◆ logp1

template<class T >
vector<double> CMCMC< T >::logp1

Log-posterior values for proposed states.

Temporary storage for evaluating proposed parameter values. Dimensions: [number_of_chains]

Definition at line 423 of file MCMC.h.

◆ MCMC_Settings

template<class T >
_MCMC_settings CMCMC< T >::MCMC_Settings

MCMC algorithm configuration settings.

All tuning parameters and flags controlling MCMC behavior. Modify before calling Perform() or initialize().

Definition at line 391 of file MCMC.h.

◆ MData

template<class T >
TimeSeriesSet<double> CMCMC< T >::MData

Measured data (observations) for likelihood calculation.

Contains observed tracer concentrations and their uncertainties. Used to calculate likelihood: p(data|θ).

Definition at line 550 of file MCMC.h.

◆ Model

template<class T >
T* CMCMC< T >::Model

Pointer to the model object being calibrated.

The model provides likelihood evaluation and predictions. For SedSat3, this is typically a SourceSinkData object.

Definition at line 334 of file MCMC.h.

Referenced by Conductor::ExecuteTestCMBBayesian(), and SourceSinkData::MCMC().

◆ Model_out

template<class T >
T CMCMC< T >::Model_out

Output model state after MCMC completion.

Contains model configured with best-fit or posterior mean parameters.

Definition at line 341 of file MCMC.h.

◆ observations

template<class T >
vector<Observation>* CMCMC< T >::observations = nullptr

Pointer to vector of Observation objects.

Contains observed tracer concentrations and measurement uncertainties. Must be set before running MCMC.

Definition at line 628 of file MCMC.h.

◆ parameters

template<class T >
vector<Parameter>* CMCMC< T >::parameters = nullptr

Pointer to vector of Parameter objects.

Contains prior distributions, ranges, and names for all parameters. Must be set before running MCMC.

Definition at line 620 of file MCMC.h.

◆ Params

template<class T >
vector<vector<double> > CMCMC< T >::Params

Parameter values for all samples and chains.

Storage structure: Params[chain_index][parameter_index] Dimensions: [number_of_chains][number_of_parameters]

Definition at line 399 of file MCMC.h.

◆ params

template<class T >
vector<int> CMCMC< T >::params

Parameter indices for model evaluation.

Maps MCMC parameter space to model parameter space. May be a subset if some parameters are fixed.

Definition at line 542 of file MCMC.h.

◆ paramsList

template<class T >
TimeSeriesSet<double> CMCMC< T >::paramsList

List of all parameter samples from MCMC.

Complete chain history after burn-in for posterior analysis.

Definition at line 761 of file MCMC.h.

◆ pertcoeff

template<class T >
vector<double> CMCMC< T >::pertcoeff

Perturbation coefficients for each parameter.

Adaptive proposal standard deviations, one per parameter. Updated during sampling to achieve target acceptance rate.

Definition at line 407 of file MCMC.h.

◆ predicted

template<class T >
CMBTimeSeriesSet CMCMC< T >::predicted

Model predictions as time series set.

Contains predicted tracer concentrations for plotting and comparison with observations.

Definition at line 512 of file MCMC.h.

Referenced by SourceSinkData::MCMC().

◆ realized_paramsList

template<class T >
TimeSeriesSet<double> CMCMC< T >::realized_paramsList

Parameter samples for posterior predictive realizations.

Subset of posterior samples used to generate model predictions.

Definition at line 768 of file MCMC.h.

◆ rtw

template<class T >
ProgressWindow* CMCMC< T >::rtw = nullptr

Pointer to progress window for GUI updates.

If not nullptr, MCMC will update progress bar and display current acceptance rate, parameter values, etc.

Definition at line 672 of file MCMC.h.

◆ temp_predicted

template<class T >
vector<CVector> CMCMC< T >::temp_predicted

Temporary storage for predicted model outputs.

Used during likelihood evaluation to store model predictions for each chain without modifying the main model object.

Definition at line 504 of file MCMC.h.

◆ total_count

template<class T >
double CMCMC< T >::total_count = 0

Count of total proposals (accepted + rejected)

Running total of all MCMC steps attempted.

Definition at line 819 of file MCMC.h.

◆ u

template<class T >
vector<double> CMCMC< T >::u

Uniform random values for Metropolis-Hastings accept/reject.

Pre-generated uniform random numbers U(0,1) for comparing with acceptance probability. Dimensions: [number_of_chains]

Definition at line 432 of file MCMC.h.


The documentation for this class was generated from the following files: