(calibration_linear_bayesian_transform)= # Transformation of the results The idea is that when you want to consider your model as linear, you may need to slightly transform it to ensure proper linear behaviour and to express and compute the needed regressors. For this particular situation, the use-case described in [](#use_cases_macro_calibration_linBayes) will be used. In this case, the `flowrate` function should be linearised as follows: ```{math} f_{\theta}(x) = \left(2 \pi T_u\right)\left(\ln(\frac{r}{r_{\omega}})\left[ 1 + \frac{2 L T_u}{\ln(\frac{r}{r_{\omega}}) r_{\omega}^2 K_{\omega}} + \frac{T_u}{T_l}\right]\right)^{-1} \theta = H \times \theta ``` where the regressor can be expressed as $H = \left(2 \pi T_u\right)\left(\ln(\frac{r}{r_{\omega}})\left[ 1 + \frac{2 L T_u}{\ln(\frac{r}{r_{\omega}}) r_{\omega}^2 K_{\omega}} + \frac{T_u}{T_l}\right]\right)^{-1}$. From this, it is clear that we will be calibrating a newly defined parameter $\theta = \left( H_u - H_l\right)$. Therefore, at some point, we will need to transform it back into our parameter of interest. This is the reason why the `setParameterTransformationFunction` method has been implemented: to transform the estimated parameters given the linear regressor, the observation covariance matrix, and the prior distribution. Since the transformations, if they exist (they are optional), are expected to be carried out using simple operations with constant values, they should affect only the mean vector and not the covariance matrix of the posterior multivariate normal distribution. The prototype of this function is as follows: ````{only} cpp ```cpp void setParameterTransformationFunction(void (*fTransfoParam)(double *in, double *out)); ``` ```` ````{only} py ```python setParameterTransformationFunction(fTransfoParam) ``` ```` Its only argument is a pointer to the transformation function. This function, used to obtain the transformed parameter values, takes two arguments: the input parameters, which are the raw values estimated from the analytical formula detailed in {{metho}}, and the output parameters, which correspond to the desired transformed values. Both arguments are double arrays of length equal to the number of parameters. The example provided in the use-case [](#use_cases_macro_calibration_linBayes) is simple as there is only one parameter to be estimated, which implies that both arguments are one-dimensional double arrays which should look like this: ```cpp void transf(double *x, double *res) { res[0] = 1050 - x[0]; // simply H_l = \theta - H_u } ``` `````{only} py ````{warning} To achieve this in Python, the function must be placed in a C file (for example, `myFunction.C`), and this file must be loaded to obtain a handle on the function. The following lines summarize these two steps in a fictional macro that defines a `cal` instance of `TLinearBayesian`: ```python # Define all the needed material: dataservers, models... cal=Calibration.TLinearBayesian(...) # Create the instance and distance function ... # Load the file in which transformation function ROOT.gROOT.LoadMacro("myFunction.C") # Provide this function to the TLinearBayesian instance cal.setParameterTransformationFunction(ROOT.transf) ``` ```` `````