(calibration_abc_construct_rejection_abc)= # Constructing the `TRejectionABC` object The constructors available for creating an instance of the `TRejectionABC` class are detailed in [](#calibration_classes_functions_observations_calibration_classes). As a reminder, the available prototypes are: ````{only} cpp ```cpp // Constructor with a runner TRejectionABC(TDataServer *tds, TRun *runner, Int_t ns=1, Option_t *option=""); // Constructor with a TCode TRejectionABC(TDataServer *tds, TCode *code, Int_t ns=1, Option_t *option=""); // Constructor with a function using Launcher TRejectionABC(TDataServer *tds, void (*fcn)(Double_t*,Double_t*), const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option="");; TRejectionABC(TDataServer *tds, const char *fcn, const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option=""); ``` ```` ````{only} py ```python # Constructor with a runner TRejectionABC(tds, runner, ns=1, option="") # Constructor with a TCode TRejectionABC(tds, code, ns=1, option="") # Constructor with a function using Launcher TRejectionABC(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 samples $ns$ must be specified, as it represents the number of retained samples in the final posterior distribution. In our implementation, the total number of computations is determined by the chosen percentile value (see [](#calibration_abc_algo_properties_percentile)). 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 `TRejectionABC` 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. The final step is to construct the `TDistanceLikelihoodFunction`, a mandatory step that must always immediately follow the constructor. Although ABC methods are Bayesian, they are likelihood-free: instead of directly computing the likelihood, they calculate the distance between the observed data and the simulated data for several prior samples, until the best-fitting distribution is identified. Consequently, the `TDistanceLikelihoodFunction` object can be constructed via the `setDistance` method (following the prototype presented in [](#calibration_classes_functions_observations_data_and_distance_recommended_distance)). Advanced users also have the option to define a custom distance by following the prototype: ````{only} cpp ```cpp void setDistance(TDistanceLikelihoodFunction *distFunc, TDataServer *tdsRef, const char *input, const char *reference, const char *weight=""); ``` ```` ````{only} py ```python setDistance(distFunc, tdsRef, input, reference, weight="") ``` ```` ```{warning} If the reference dataset is compared against a deterministic model (i.e. a model with no intrinsic stochasticity), it is necessary to explicitly specify the uncertainty hypotheses. This is done via the method described in [](#calibration_abc_algo_properties_noise_deterministic). ```