11.2.2. Defining data, distance and likelihood functions

The different distance and likelihood functions already embedded in Uranie can be found in Distances and likelihoods used to compare observations and model predictions and are further discussed from a theoretical point of view in [Bla17]. From the user point of view, on the other hand, every distance or likelihood function inherits from the class TDistanceLikelihoodFunction, as can be seen in Figure 11.1, which is purely virtual (meaning that no object can be instantiated as TDistanceLikelihoodFunction) and serves several main purposes:

  • it loads the reference data once and stores them internally as a vector of vectors (or as a vector of TMatrixD, depending on the chosen formalism used to compute the distance or likelihood);

  • once done, the following loop is executed as long as new configurations need to be tested (a configuration being defined as a new set of values for vector \(\theta\)):

    1. it runs the chosen model regardless of the nature of the object (TRun, TCode, etc.) on the full reference dataset to get the new predictions;

    2. it loads the new model predictions for the configuration under study into a vector of vectors (or as a vector of TMatrixD depending on the chosen formalism);

    3. it computes the distance or likelihood using both vectors as statd by the equations in Distances and likelihoods used to compare observations and model predictions. This computation is done within the localeval method (which is the only method that should be redefined if a user wants to create its own distance or likelihood function, see dedicated discussion in Creating its own distance or likelihood function).

From a technical point of view, the TDistanceLikelihoodFunction inherits from the TDoubleEval class which is a part of the Relauncher module. This inheritance is not very important as its main appeal is to considerably simplify the implementation of the minimisation methods with the Reoptimizer module, allowing the straightforward use of all TNlopt algorithms as well as Vizir solutions (see Minimisation techniques).

Regardless of the calibration method considered, a distance or likelihood function must be used to compare data and model predictions. This is even true for the TLinearBayesian class, which directly computes the analytical posterior distribution, as the residuals are computed both a priori and a posteriori to assess the improvement of the prediction and their consistency within the uncertainty model (see discussion in [Bla17]). In most cases the object will be constructed with a recommended way (discussed in Recommended distance and likelihood functions, construction method). Another possibility is also discussed in Creating its own distance or likelihood function

Whatever the situation, once a calibration instance is created (for the sake of generality, we will use an instance named cal, of the mock class TCalClass, as if it inherited from the TCalibration class), the first method to be called is the setDistance or setLikelihood depending on the framework used (see the corresponding section), as this is the method which defines both the type of distance or likelihood function and the observation dataset.