11.4.3.1. 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 Macro “calibrationLinBayesFlowrate1D.C” will be used. In this case, the flowrate function should be linearised as follows:

\[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:

void setParameterTransformationFunction(void (*fTransfoParam)(double *in, double *out));

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 [Bla17], 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 Macro “calibrationLinBayesFlowrate1D.C” 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:

void transf(double *x, double *res)
{
    res[0] = 1050 - x[0];  // simply H_l = \theta - H_u
}