# Bayesian Inference with RSME

Hi all!

I have been using UQLab for a few months now and would like to thank you for making it available.

I mainly use the library for Bayesian inference for model calibration have come across query on how one could use UQ lab, particularly the inversion stage, to fit a curve of points rather than individual points. I can imagine that you could define multiple forward models, as given in the example/documentation but this might be a bit cumbersome once you have more than say, 4 points of interest.

If for example, you could use root-mean-square error (RMSE) as an objective function, instead of discrete measurements, you could in theory (and as many researchers have done in literature) fit the whole curve.

Can someone help with this question?

Thanks!

Truong

Hi @Truong_Le,

Thanks for asking here. Actually, I do not really understand what you mean about “fit a curve of points”. Do you want to use Bayesian regression or perform model calibration? Could you please explain a bit more in details?

Best regards,
Xujia

%% 2 - COMPUTATIONAL MODEL WITH UQLINK (WRAPPER)
%
iterate = false;

%% 3 - PROBABILISTIC INPUT MODEL
%
% 3.1 Input parameters (Prior distribution)
Initial = cell(3,1);
Initial_mean = [10E+3 100];
Initial_std = [1E+3 10];
Initial_name = {'E', 'Su'};
numberofVariables = length(Initial_name);

% Create the INPUT object
myInput = DataInput(Initial_mean,Initial_std,Initial_name);

% 4 - SAMPLING FROM PDF AND EVALUATE MODEL

% of samples via Latin Hypercube sampling:
NumberofSamples = 5;
Data_samples=[];
numerical_output=[];
[numerical_output,Data_samples] = Evaluatemodel(NumberofSamples,iterate,Data_samples,numerical_output);

%################# End of UQLINK interaction ###########################

%%

%% 4.2 POLYNOMIAL CHAOS EXPANSION (PCE)

% Threshold for "serviceability/ultimate limit"
Threshold = cell(1,2);
Threshold{1,1} = [0 197 351 410 600]; % I Know this line doesnt work.
Threshold{1,2} = '>=';

[myPCE, myMCS] = SurrogateModel(numerical_output, Data_samples, Threshold);

% 5 - MEASUREMENT DATA

myData.y = [0 197 351 410 546];

% 6 - BAYESIAN ANALYSIS

myBayesianAnalysis_surrogateModel = BayesianAnalysis(myData, myPCE);



A snippet of the code in question is provided.

I have found that I can likely run the Bayesian inversion problem with a (m x n) array of outputs (as suggested in the Hydro example problem). I am however wondering if this could be combined with surrogate modelling. The code works perfectly fine, and as expected, when I only provide a single numerical value for “numerical_output” with any number of rows (m x 1). The functions I call work principally the same as in the examples, just separated them to clear up the code.

I am basically asking: can I do " INVERSION: SURROGATE MODEL ACCELERATED CALIBRATION" with the profile of displacement (“curve of points”) instead of the single center point?

My thinking was that I can reduce the (m x n) inversion problem down to a (m x 1) problem by looking at the RMSE instead of the whole deflection profile – if that makes sense.

Hi @Truong_Le,

Thanks for the clarification. If I understand correctly, you want to perform Bayesian inversion for models with multiple outputs based on deflections of 5 points of a structure. If so, the Hydro example is the right one to refer to: it has N_{\rm out}=731 outputs. Note that the output is NOT a m\times n matrix. The reason you see it as a matrix is that the function is vectorized (by setting Vectorized = true), meaning that it can be evaluated for multiple values of the input variables at once (see Page 4 and Section 2.4 of the model manual).

To accelerate the inversion, you can build a surrogate model for your multiple-output model. Please refer to Section 2.10 of the PCE manual and the example uq_Example_PCE_04_MultipleOutputs (or this one https://www.uqlab.com/pce-multiple-outputs) for more details. Then, you can simply use the emulator as a computational model to perform the calibration.

I hope this helps.

Best regards,
Xujia

Many thanks for pointing me to the appropriate examples! I will give it a go this weekend. 