Hello everyone,
I am very new to UQ and sensitivity analysis, and I am getting the following error trying to use similar method as the borehole example.
--- Calculating the PCE coefficients by regression. ---
Error using uq_lar (line 403)
Unable to perform assignment because the left and right sides have a different number of elements.
Error in uq_PCE_lars (line 64)
lar_results = uq_lar(Psi, Y, lar_options);
Error in uq_PCE_calculate_coefficients_regression (line 196)
lars_results = uq_PCE_lars(univ_p_val, current_model);
Error in uq_PCE_calculate_coefficients (line 47)
uq_PCE_calculate_coefficients_regression(current_model);
Error in uq_calculateMetamodel (line 18)
success = uq_PCE_calculate_coefficients(current_model);
Error in uq_initialize_uq_metamodel (line 458)
success = uq_calculateMetamodel(current_model);
Error in uq_core_module/run_initialization_script (line 208)
initHandle(obj);
Error in uq_core_model/add_module (line 100)
success = this.run_initialization_script(obj);
Error in uq_createModel (line 116)
eval(str);
Error in Sens_analysis (line 77)
myPCE = uq_createModel(PCEOpts);
My model looks like following, where y is the predicted impact load of a flat head on a beam in a pendulum test. rho and T are measured experimentally, where T is really not normal distributed but is varying depending on the dimensions (b,h,l).
It is possible to simplify the model by making E a gaussian distribution [12.4 1.7], however I get the same error…
function [y] = ForcePredict(xx)
v = xx(1);
b = xx(2);
h = xx(3);
l = xx(4);
rho = xx(5);
T = xx(6);
E = 48*(l - 180)^3*l*rho*10^(-9)/(pi^2*T^2*h^2);
y = (3*3475*v^2*E*b*240/h/(4*(3475/(rho*b*l*h + 1))))^(1/2);
And my input data as follows. Using this exact code but changing the input to borehole works just fine.
% 2 - COMPUTATIONAL MODEL
ModelOpts.mFile = 'ForcePredict';
myModel = uq_createModel(ModelOpts);
% 3 - PROBABILISTIC INPUT MODEL
InputOpts.Marginals(1).Name = 'v'; % impact velocity
InputOpts.Marginals(1).Type = 'Uniform';
InputOpts.Marginals(1).Parameters = [9.51 9.57]; % (m/s)
InputOpts.Marginals(2).Name = 'b'; % width (impact 'height')
InputOpts.Marginals(2).Type = 'Uniform';
InputOpts.Marginals(2).Parameters = [160 200]; % (mm)
InputOpts.Marginals(3).Name = 'h'; % height
InputOpts.Marginals(3).Type = 'Uniform';
InputOpts.Marginals(3).Parameters = [160 320]; % (mm)
InputOpts.Marginals(4).Name = 'l'; % length
InputOpts.Marginals(4).Type = 'Uniform';
InputOpts.Marginals(4).Parameters = [2900 4300]; % (mm)
InputOpts.Marginals(5).Name = 'rho'; % density
InputOpts.Marginals(5).Type = 'Gaussian';
InputOpts.Marginals(5).Parameters = [480 40]; % (kg/m^3)
InputOpts.Marginals(6).Name = 'T'; % Period from vibration test
InputOpts.Marginals(6).Type = 'Uniform';
InputOpts.Marginals(6).Parameters = [15 35]; % (ms)
% Create an INPUT object based on the specified marginals:
myInput = uq_createInput(InputOpts);
% Select the sensitivity analysis module in UQLab and the Sobol' analysis method:
SobolOpts.Type = 'Sensitivity';
SobolOpts.Method = 'Sobol';
% Specify the maximum order of the Sobol' indices to be calculated:
SobolOpts.Sobol.Order = 1;
% Specify the sample size for the MC simulation:
SobolOpts.Sobol.SampleSize = 1e5;
% 4.2 PCE-based Sobol' indices
% Select the metamodeling tool in UQLab and the polynomial chaos expansion (PCE) type:
PCEOpts.Type = 'Metamodel';
PCEOpts.MetaType = 'PCE';
% Assign the full computational model:
PCEOpts.FullModel = myModel;
% The full model is used to generate an experimental design for the PCE.
% Specify the maximum polynomial degree (default: sparse PCE):
PCEOpts.Degree = 5;
% Specify the size of the experimental design (i.e., the total computational cost of constructing the metamodel):
PCEOpts.ExpDesign.NSamples = 200;
% Calculate the PCE:
myPCE = uq_createModel(PCEOpts);
% The same options structure SobolOpts can be re-used to create a new analysis on the PCE model:
mySobolAnalysisPCE = uq_createAnalysis(SobolOpts);
% Retrieve the results for comparison:
mySobolResultsPCE = mySobolAnalysisPCE.Results;
uq_print(mySobolAnalysisPCE)
Any feedback is greatly appreciated
Thank you in advance!