# PCE for high-dimensional variables

I have 23 Gaussian variables and 605 CFD simulation results. I need to build a PCE model and settle the Sobol exponent, variance, mean to analyze the uncertainty, I also tried LARS, MC, OMP and other methods to solve, but the output of the OLOO error seems to be greater than 0.2 resulting in inaccurate results, I hope to get your help to help me solve this problem.

``````clearvars
uqlab
X=importdata('datafile\sample.txt');
Y=importdata('datafile\2.7.txt');
inputset={'X1','Gaussian',[1.45E+12,3.5875E+11];'X2','Gaussian',[181000000,44797500];'X3','Gaussian',[6.02E+10,1.48995E+10];'X4','Gaussian',[1.14E+7,2.82E+06];'X5','Gaussian',[3.63E+13,8.98E+12];'X6','Gaussian',[1.09E+9,2.7E+9];'X7','Gaussian',[3.63E+13,8.98E+12];'X8','Gaussian',[1.6E+15,1.6E+14];'X9','Gaussian',[1.69E+5,4.18E+4];'X10','Gaussian',[2.54E+10,6.29E+9];'X11','Gaussian',[2.5E+10,6.19E+9];'X12','Gaussian',[1.4E+12,3.47E+11];'X13','Gaussian',[9.4E+22,2.33E+22];'X14','Gaussian',[1.6E+7,3.96E+6];'X15','Gaussian',[2.3E+15,5.69E+14];'X16','Gaussian',[4E+11,9.9E+10];'X17','Gaussian',[2E+9,4.95E+8];'X18','Gaussian',[8.43E+7,2.09E+7];'X19','Gaussian',[3.01E+8,7.45E+7];'X20','Gaussian',[3.61E+7,8.93E+6];'X21','Gaussian',[9.03E+8,2.23E+8];'X22','Gaussian',[3.62E+3,8.96E+2];'X23','Gaussian',[1.45E+11,3.95E+10]}

for i=1:size(inputset,1)
for i=1:size(inputset,1)
InputOpts.Marginals(i).Name = inputset{i,1};
InputOpts.Marginals(i).Type = inputset{i,2};
InputOpts.Marginals(i).Parameters= inputset{i,3};
end
end
myInput = uq_createInput(InputOpts);
MetaOpts.Type = 'Metamodel';
MetaOpts.MetaType = 'PCE';
MetaOpts.ExpDesign.X = X;
MetaOpts.ExpDesign.Y = Y;
MetaOpts.Degree = 2:10;
PCEOpts.TruncOptions.qNorm = 0.3:0.5;
PCEOpts.TruncOptions.MaxInteraction = 2
MetaOpts.Method = 'LARS';%LARS,BCS,OMP,OLS(求解器：稀疏，最小二回归，)
MetaOpts.ExpDesign.NSamples = size(X,1);
MetaOpts.truncOotions.Macinteraction=2;
myPCE = uq_createModel(MetaOpts);
myPCE = uq_createModel(MetaOpts);
uq_print(myPCE)
for i=1:size(Y,2)
Mean(i)= myPCE.PCE(i).Moments.Mean;
var(i)=myPCE.PCE(i).Moments.Var;
std(i) = (myPCE.PCE(i).Moments.Var).^(0.5);
end
%%
SobolOpts.Type = 'Sensitivity';
SobolOpts.Method = 'Sobol';
SobolOpts.Sobol.Order = 2;
SobolOpts.Sobol.SampleSize = size(X,1);
mySobolAnalysisPCE = uq_createAnalysis(SobolOpts);
mySobolResultsPCE = mySobolAnalysisPCE.Results;
SobolTotal = mySobolResultsPCE.Total;
SobolFirstOrder =mySobolResultsPCE.FirstOrder;
``````

Dear @MAJIE123

Before I dive into further details: I’m a little confused by this nested for loop:

``````for i=1:size(inputset,1)
for i=1:size(inputset,1)
InputOpts.Marginals(i).Name = inputset{i,1};
InputOpts.Marginals(i).Type = inputset{i,2};
InputOpts.Marginals(i).Parameters= inputset{i,3};
end
end
``````

The inner loop variable shadows the outer one. Is this really what you want?

Best regards
Styfen

This cycle is equivalent to reading the sample information, the sample name, the sample distribution type, and the sample size

I wanted to say that you can simply write this with a single loop:

``````for i = 1:size(inputset, 1)
InputOpts.Marginals(i).Name = inputset{i, 1};
InputOpts.Marginals(i).Type = inputset{i, 2};
InputOpts.Marginals(i).Parameter = inputset{i, 3};
end
``````

So I was wondering if there is a major logical error in your code.

There are a few other things I notice:

• You have an unused structure `PCEOpts`. Should this be part of `MetaOpts`?
• You have the line `myPCE = uq_createModel(MetaOpts);` twice
• `MetaOpts.truncOotions.Macinteraction=2` is not a valid field

I think the first step should be to clean up your code and make sure it does what you intend.