Hi all,
I get an error in UQLab when the number of fields of the prior distribution do not match with the number of fields of the prior for the discrepancy options.
Here’s a short working example:
uqlab;
%% model
Model.mString = 'X(:,1)';
myModel = uq_createModel(Model);
%% prior
PriorOpts.Marginals(1).Type = 'Gaussian';
PriorOpts.Marginals(1).Parameters = [0 1];
PriorOpts.Marginals(1).Bounds = [-3 3];
myPrior = uq_createInput(PriorOpts);
%% data
myData(1).y = [0; 1; 2];
myData(1).MOMap = 1;
%% likelihood and hyperparameters
DiscrepancyPriorOpts1.Name = 'Prior of sigma 1';
DiscrepancyPriorOpts1.Marginals(1).Name = 'Sigma1';
DiscrepancyPriorOpts1.Marginals(1).Type = 'Uniform';
DiscrepancyPriorOpts1.Marginals(1).Parameters = [0 2];
DiscrepancyPrior1 = uq_createInput(DiscrepancyPriorOpts1);
DiscrepancyOpts(1).Type = 'Gaussian';
DiscrepancyOpts(1).Prior = DiscrepancyPrior1;
%% Bayes
BayesOpts.Prior = myPrior; % Prior
BayesOpts.Data = myData; % Measurement data
BayesOpts.Type = 'Inversion'; % Calibration
BayesOpts.Discrepancy = DiscrepancyOpts; % Likelihood
BayesianAnalysis = uq_createAnalysis(BayesOpts);
The resulting error is:
Number of fields in structure arrays being concatenated do not match. Concatenation
of structure arrays requires that these arrays have the same set of fields.
When I comment the line
PriorOpts.Marginals(1).Bounds = [-3 3];
everything works as expected.
It seems that in uq_mergeInputs it is expected that the Marginals for PriorOpts and DiscrepancyOpts have the same number of fields. Why is this? I would expect it is possible to have a truncated Gaussian for the prior, while I have a regular Gaussian for the hyperparameters?
Is there a fix or workaround for this? Or am I simply overlooking something here?
Best,
Benjamin