# PCE-based Sobol’ indices with Existing Simulation Data

Greeting,

I want to ask if it is possible to use existing simulation data to calculate the PCE-based Sobol indices.

Assuming I created my design of the inputs with uq_getSample syntax in the UQ lab. The output are obtained from a FEM solver.

Is that possible? Or do I always need to use the UQ link to connect the UQ lab and the computational model?

1 Like

Hi @sahuqa ,

Yes, this is possible! See the PCE User Manual, Section 2.5 for an explanation how to manually specify an experimental design.

1 Like

Thanks for your quick response. That section of the manual contains what I need.

1 Like

myInput = uq_createInput(InputOpts);

MetaOpts.Type = ‘Metamodel’;
MetaOpts.MetaType = ‘PCE’;

MetaOpts.ExpDesign.X = X_sample100;
MetaOpts.ExpDesign.Y = Y_sample100;

MetaOpts.Degree = 1:5;

MetaOpts.ValidationSet.X = Xval;
MetaOpts.ValidationSet.Y = Yval;

myPCE = uq_createModel(MetaOpts);

uq_print(myPCE)

YPCE = uq_evalModel(myPCE,Xval);

uq_figure

cmap = uq_colorOrder(2);
uq_histogram(Yval, ‘FaceColor’, cmap(1,:))
hold on
uq_histogram(YPCE, ‘FaceColor’, cmap(2,:))
hold off

xlabel(’\mathrm{Y}’)
ylabel(‘Counts’)
uq_legend(…
{‘True model response’, ‘PCE prediction’},…
‘Location’, ‘northwest’)

Hi! Above is my code according to the example “PCE from existing data: Truss data set”,but in the histogram the counts are not integers but decimals,besides ‘True model response’ in color blue is not displayed, why?

Hi @AmosJoseph ,

Welcome to UQWorld! Small hint: if you start and end the code section with  (three apostrophes), the code will be displayed properly as code and not as plain text. And please, next time you ask a question that is not directly related to an existing one: just open a new topic. Thanks!

1. by default, uq_histogram normalizes the histogram, as explained in the beginning of the file uq_histogram.m:
%   UQ_HISTOGRAM(Y) plots a histogram of a column- or row-vector Y with
%   normalized values (i.e., the total area under the histogram is 1.0).

1. My guess is that Yval and YPCE are identical and therefore the blue histogram is completely covered by the orange one… is that possible? Is your model a polynomial?

Yes,It is PCE,but it is not normalized in my model,why ?

I’m not sure what you mean with “PCE that is not normalized”, can you clarify?

1. I meant that the values of the histogram are plotted normalized (see here for an explanation of different normalization options, although uq_histogram is not based on Matlab’s histogram function)

2. Regarding your second question, if you set a breakpoint in your code at the line saying hold on, you should see the blue histogram before it is covered by the orange histogram.

By default, uq_histogram normalizes the histogram, but in my case, the histogram is not normalized.Why?

As you observed, uq_histogram does not plot plain counts (=integers), but normalized values so that the total area under the histogram is 1.0. You can check line 134 in uq_histogram.m` to see how the normalization factor is computed from your data.