(calibration_markov_chain_tmcmc)= # Constructing the `TMCMC` object The constructors available for creating an instance of the `TMCMC` class are detailed in [](#calibration_classes_functions_observations_calibration_classes). As a reminder, the available prototypes are: ````{only} cpp ```cpp // Constructor with a runner TMCMC(TDataServer *tds, TRun *runner, Int_t ns=1, Option_t *option=""); // Constructor with a TCode TMCMC(TDataServer *tds, TCode *code, Int_t ns=1, Option_t *option=""); // Constructor with a function using Launcher TMCMC(TDataServer *tds, void (*fcn)(Double_t*,Double_t*), const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option=""); TMCMC(TDataServer *tds, const char *fcn, const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option=""); ``` ```` ````{only} py ```python # Constructor with a runner TMCMC(tds, runner, ns=1, option="") # Constructor with a TCode TMCMC(tds, code, ns=1, option="") # Constructor with a function using Launcher TMCMC(tds, fcn, varexpinput, varexpoutput, ns=1, option="") ``` ```` Details about these constructors can be found in [](#calibration_classes_functions_observations_calibration_classes_runner), [](#calibration_classes_functions_observations_calibration_classes_tcode), and [](#calibration_classes_functions_observations_calibration_classes_function_launcher_archi) respectively for the `TRun`, `TCode`, and `TLauncherFunction`-based constructor. In all cases, the number of iterations $ns$ must be specified. This class provides one specific option, which can be used to modify the default value of the *a posteriori* distribution returned by the algorithm. Two possible choices are available for obtaining the single-point estimate that best represents the distribution: - Mean of the distribution: this is the **default** option; - Mode of the distribution: the user must specify **"mode"** in the option field of the `TMCMC` constructor. The default solution is straightforward, whereas the second requires internal smoothing of the distribution in order to obtain the best estimate of the mode. In practice, the constructor—whichever one is chosen—initializes a folder named `MCMC_N`, where N is an integer ensuring the folder name is available. This folder contains all the information related to the MCMC calculation (the chain values, the algorithm used, the number of accepted samples, etc.), with each chain stored in a separate file named `MCMC_N_chain_M` (for the M-th chain, starting from 0). By default, only one chain is initialized, so the `MCMC_N` folder contains a single file `MCMC_N_chain_0`. This folder will be duplicated once the `setMultistart` method is called (see [](#calibration_markov_chain_mcmc_properties_multistart)). The files are automatically loaded and saved during the computation. The next step is to construct the `TDistanceLikelihoodFunction`, a mandatory step that must always immediately follow the constructor. For now, the only available likelihood function is the Gaussian, as it is the most commonly used. It can be accessed through the classic `setLikelihood` method using the function name `"log-gauss"`, following the standard prototype (presented in [](#calibration_classes_functions_observations_data_and_distance_recommended_distance)). As previously explained, in this case the weights provided to the constructor correspond to the standard deviations of each observation. Advanced users also have the option to define a custom likelihood by following the prototype: ````{only} cpp ```cpp void setLikelihood(TDistanceLikelihoodFunction *likelihoodFunc, TDataServer *tdsRef, const char *input, const char *reference, const char *weight=""); ``` ```` ````{only} py ```python setLikelihood(likelihoodFunc, tdsRef, input, reference, weight="") ``` ````