(calibration_linear_bayesian_tlinearbayesian)= # Constructing the `TLinearBayesian` object The constructors available for creating an instance of the `TLinearBayesian` class are detailed in [](#calibration_classes_functions_observations_calibration_classes). As a reminder, the available prototypes are: ````{only} cpp ```cpp // Constructor with a runner TLinearBayesian(TDataServer *tds, TRun *runner, Int_t ns=1, Option_t *option=""); // Constructor with a TCode TLinearBayesian(TDataServer *tds, TCode *code, Int_t ns=1, Option_t *option=""); // Constructor with a function using Launcher TLinearBayesian(TDataServer *tds, void (*fcn)(Double_t*,Double_t*), const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option=""); TLinearBayesian(TDataServer *tds, const char *fcn, const char *varexpinput, const char *varexpoutput, int ns=1, Option_t *option=""); ``` ```` ````{only} py ```python # Constructor with a runner TLinearBayesian(tds, runner, ns=1, option="") # Constructor with a TCode TLinearBayesian(tds, code, ns=1, option="") # Constructor with a function using Launcher TLinearBayesian(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$ is set to 1 by default, and modifying it has no effect on the results, since it returns the analytical distributions. This class does not define any specific options. The final step is to construct the `TDistanceLikelihoodFunction`, a mandatory step that must always immediately follow the constructor. This can be done via the `setLikelihood` method (following the prototype presented in [](#calibration_classes_functions_observations_data_and_distance_recommended_distance)). `````{warning} The Analytical Linear Bayesian Estimation method relies on the assumption that residuals are Gaussian (centered) with a defined covariance matrix (see [](#calibration_linear_bayesian_linear_model)). As a result, the likelihood is not a free choice but is determined by these assumptions. It is important to note that the `setLikelihood` method is used only for residual calculation, to compare the prior and posterior. Regardless of the initial choice of likelihood, the function is locally redefined so that the computation is performed via the `lin_gauss` function using matrix multiplication (through the `TMahalanobisDistance` method). Although not recommended, it is still possible to define a custom likelihood function: ````{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="") ``` ```` `````