I am trying to use the Monte Carlo, Sobol, Halton and Latin hipercube sampling strategies for a test function written by me.

Monte Carlo method works but the others sampling methods not and I do not understand what is the error. for completness I write the code:

clearvars

rng(100,‘twister’)

uqlab

ModelOpts.mString = ‘X-*sin(X).*cos(X)’;

ModelOpts.isVectorized = true;

myModel = uq_createModel(ModelOpts);

IOpts.Marginals.Type = ‘uniform’;

IOpts.Marginals.Parameters = [0 , 6];

myInput = uq_createInput(IOpts);

X_MC = uq_getSample(20,‘MC’);

Y_MC = uq_evalModel(myModel,X_MC);

X_LHS = uq_getSample(20,‘LHS’);

Y_LHS = uq_evalModel(myModel,X_LHS);

X_H = uq_getSample(20,‘Halton’);

Y_H = uq_evalModel(myModel,X_H);

X_S = uq_getSample(20,‘Sobol’);

Y_S = uq_evalModel(myModel,X_S);

Dear @SimoneRomani12

Can you describe in more detail what did not work and what error you get?

Regardless, I notice that you have an invalid `mString`

.

`X-*sin(X).*cos(X)'`

is not a valid Matlab syntax. Change it to `'X-sin(X).*cos(X)'`

.

Best regards

Styfen

Dear Styfen,

thank you very much for your answer, there is one mistake in the formula that I sent, in fact the right equation is X*sin(X)*cos(X).

When I compute the code I have the following error message:

Error using uq_lhs

Undefined function ‘lhsdesign’ for input arguments of type ‘double’.

Dear @SimoneRomani12

With the corrected m-string it works fine for me. Can you run the exact code below and post the full error message if it still doesn’t work?

```
clearvars
rng(100,'twister')
uqlab
ModelOpts.mString = 'X .* sin(X) .* cos(X)';
ModelOpts.isVectorized = true;
myModel = uq_createModel(ModelOpts);
IOpts.Marginals.Type = 'uniform';
IOpts.Marginals.Parameters = [0 , 6];
myInput = uq_createInput(IOpts);
N = 1e3;
X_MC = uq_getSample(N,'MC');
Y_MC = uq_evalModel(myModel,X_MC);
X_LHS = uq_getSample(N,'LHS');
Y_LHS = uq_evalModel(myModel,X_LHS);
X_H = uq_getSample(N,'Halton');
Y_H = uq_evalModel(myModel,X_H);
X_S = uq_getSample(N,'Sobol');
Y_S = uq_evalModel(myModel,X_S);
```

Dear Styfen,

thank you very much for your support, unfortunatelly the code does not work yet.

I send you the complete matlab error message and for completeness I say you that I downloaded UQLab 2.0.0 folder and I created this ‘‘matlab exercize’’ inside the ‘‘core’’ folder, maybe the position of my matlab file is wrong.

The error messages are:

Error using uq_lhs

Undefined function ‘lhsdesign’ for input arguments of type ‘double’.

Error in uq_sampleU (line 54)

u = uq_lhs(N, M, 0, options.LHSiterations);

Error in uq_default_input (line 104)

u(:,indNonConst) = uq_sampleU(N, M,samplingOptions);

Error in uq_getSample (line 42)

[varargout{1:nargout}] = current_input.getSample(current_input,varargin{:});

Error in Experiment_1_PCE (line 32)

X_LHS = uq_getSample(N,‘LHS’);

Dear Styfen,

Using Matlab R2020b the code runs instead using Matlab R2022b the code does not work.

In conclusion I think the problem is associated to the Matlab version (maybe some package is not installed) , I will use the first version to avoid potential problems.

Thank you so much for your help.