# Computing Sobol sensitivity indices using existing input/output data

**URL:** <https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327>\
**Category:** Community Q&A and How To\
**Tags:** sensitivity, sobol, metamodeling\
**Created:** [December 6, 2019, 9:22pm UTC](https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327 "2019-12-06T21:22:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gull\_Rana](https://uqworld.org/user_avatar/uqworld.org/gull_rana/32/337_2.png) [@Gull\_Rana](https://uqworld.org/u/Gull_Rana)\
**Post date:** [December 6, 2019, 9:22pm UTC](https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327/1 "2019-12-06T21:22:57Z")

</div>

> [@Getting started with uncertainty quantification (UQ)](https://uqworld.org/t/getting-started-with-uncertainty-quantification-uq/128):
>
> Introduction Uncertainty quantification (UQ) has become a hot topic in virtually all domains of applied sciences and engineering in the last decade. In the research community, this relatively new field lies at the boundary of applied mathematics, statistics, and computational engineering sciences. In the last few years, not only the number of scientific publications in this area has blown up, but also new scientific journals[[1]](#footnote-151-1) devoted to this topic have emerged. In parallel, several books, most…

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

---

<div class="post-metadata">

**Author:** ![bsudret](https://uqworld.org/user_avatar/uqworld.org/bsudret/32/224_2.png) [@bsudret](https://uqworld.org/u/bsudret)\
**Post date:** [December 7, 2019, 4:44pm UTC](https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327/2 "2019-12-07T16:44:25Z")

</div>

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](https://www.uqlab.com/pce-truss-data-set) 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:

```matlab
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](http://uqftp.ethz.ch/uqlab_doc_pdf/1.3.0/UserManual_Sensitivity.pdf) if needed):

```matlab
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](https://www.sobolindices.com/), which exactly follows the procedure described above.

I hope it will be helpful!  
Best regards  
Bruno

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [December 9, 2019, 8:28am UTC](https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327/3 "2019-12-09T08:28:51Z")

</div>

This is a relevant question for other community members.

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [December 9, 2019, 3:30pm UTC](https://uqworld.org/t/computing-sobol-sensitivity-indices-using-existing-input-output-data/327/4 "2019-12-09T15:30:17Z")

</div>

Similar question as in

> [@Sensitivity analysis for multi outputs, if the output is calculated by simulations](https://uqworld.org/t/sensitivity-analysis-for-multi-outputs-if-the-output-is-calculated-by-simulations/322):
>
> Hi, I am very new to UQlab, I installed it and try to apply the sensitivity analysis for multi outputs, I am using polynomial regression as a model since my outputs are in table form. I am trying to apply for my problem same by following the given example for multi outputs but all in vain. Can anyone of you give me an idea that how to use UQlab for non analytical functions.
