# Computing Sobol sensitivity indices using existing input/output data

hi,

I am sorry to bother you, I am new to UQlab and trying to find the sensitivity indices for my problem. I don’t have any specific handler function as a model to calculate the outputs. I created the samples for the input parameters and simulated the outputs by a FEM based software. Now I have input set and output set. I am trying to apply the sensitivity in the Same way of example of sensitivity for multi outputs. But all in vain. Can you please guide me that how can I define the model and use my data to find the sensitivity indices. I will be highly grateful to you.

Best Regards

Gullnaz Shahzadi

Dear Gullnaz

You have to construct a surrogate model of your finite element model from your runs first. In order to do sensitivity analysis afterwards, a good choice is to use polynomial chaos expansions (PCE). The Polynomial chaos expansion from existing data example is a good starting point.

### Polynomial chaos expansion

Following this example, you start by defining the distribution of the input parameters of the FE model (the distributions you used to sample the inputs). If you did this step with UQLab, simply reuse your UQLab input object.

Then you build a PCE as follows:

```
MetaOpts.Type = 'Metamodel';
MetaOpts.MetaType = 'PCE';
MetaOpts.ExpDesign.X = <your matrix of inputs>;
MetaOpts.ExpDesign.Y = <your matrix of outputs>;
MetaOpts.Degree = 1:5;
%
myPCE = uq_createModel(MetaOpts);
```

Your input data should be organized in a N \times M matrix, where M is the number of input parameters of your problem and N the number of runs you did. Accordingly your output data (the response of the finite element model) should be organized in a N \times Q matrix, where Q is the number of output quantities of interest (I suggest you start with Q=1 first). Make sure that the lines of the input and output correspond !

### Computation of Sobol’ indices

You can carry out sensitivity analysis using these few lines of codes (many more options can be set up, see the documentation if needed):

```
SobolOpts.Type = 'Sensitivity';
SobolOpts.Method = 'Sobol';
SobolOpts.Sobol.Order = 1;
mySobol = uq_createAnalysis(SobolOpts);
uq_print(mySobol) % print the Sobol' indices
uq_display(mySobol) % display the Sobol' indices
```

Note that if you have uniform distributions for your input variables (*only in this case*), you can get the same results using the online Sobol’ index calculator, which exactly follows the procedure described above.

I hope it will be helpful!

Best regards

Bruno

This is a relevant question for other community members.

Similar question as in