# PCE Metamodel

Hi all,
I am new to using UQLab.

I am trying to create a PCE metamodel of a function that could take in a sampled input of distribution (a vector of 1 dimension with an arbitrary amount of samples). There are 200 output values to my model no matter how many inputs there are. The model function is not intended to calculate the output for each input sample, but use an input distribution for the calculation of 200 outputs.

I have sampled a uniform distribution by 100 samples LHS as input X [10x100], calculating 200 outputs Y [10x200].

I’ve used the following lines of code for PCE metamodelling:

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

MetaOpts.ExpDesign.X = X;
MetaOpts.ExpDesign.Y = Y;

MetaOpts.Degree = 1:5;

myPCE = uq_createModel(MetaOpts);
uq_print(myPCE)

Update: if the input to the model is a vector, how are we to define the marginals? This is the error I received.

Index exceeds the number of array elements (10).

Error in uq_GeneralIsopTransform (line 42)
Y(:,ii) = Y_Marginals(ii).Parameters;

Error in uq_getExpDesignSample (line 148)
U = uq_GeneralIsopTransform(X, current_input.Marginals, current_input.Copula, PolyMarginals,
PolyCopula);

Error in uq_PCE_calculate_coefficients_regression (line 32)
[current_model.ExpDesign.X, current_model.ExpDesign.U] = uq_getExpDesignSample(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 358)
success = uq_calculateMetamodel(current_model);


Any help or tips would be much appreciated.
Thank you.

Hi @AHz,

Welcome to UQWorld! I would like to better understand the setup of your model.

1. Consider the function that generates your data y={\cal M}(x), where x denotes the input vector, and y corresponds to the model response. The output y has a dimension of 200, which is independent of the dimension of x. Is this a general setup for a set of problems or for a specific model? Because for a given physical model, we should have well-defined input variables. Otherwise, the physical model {\cal M} itself is rather vague.
2. In the code, you have a design matrix of x with 10 \times 100 and the model responses y with 10 \times 200. Does this mean that x \in \mathbb{R}^{100} and you generate 10 samples of x? Note that in UQLab, a design matrix N \times M means that you have a vector input of dimension M and N realizations (the same notation holds for multiple-output models).
3. If the input is a vector, you should define the marginal distribution for each component of X (and also possibly copulas for dependent components). Please refer to the input manual and the PCE manual for details.

I hope this helps.

Thank you for your response Xujia, that was really helpful. I was able to figure it out, thanks!!