Effect of PMap: Documentation and Implementation seem do differ

Hello,

to prepare myself to implement to perform a Bayesian Inversion with many models, I have done some extensive testing and modifications of the examples and it seems to me that the effect of using PMap in the documentation and in the implementation seem to differ: Using

forwardModels(2).PMap = [1 2 3 4 6]

as in the example file “uq_Example_Inversion_05_MultipleModels.m” should imply (according to my understanding of the documentation and of comments in the example files) that during the Bayesian Inversion Analysis performed by calling uq_createAnalysis the function in the model is evaluated with
samples for the random variables 1,2,3,4 and 6 that are collected in a vector with 5 components.
Hence, the functions in the 2nd model in the example file is originally defined by

ModelOpts2.mString = ‘X(:,5).*X(:,3)./(X(:,1).*X(:,2).*X(:,4))’;

But, transforming this definition into a function in a file and using the
matlab debugger, I observed that the input for this function is a vector with 6 components and that the component no. 5 is always equal to 0.

Hence, it seems to me that the effect of the above definition for PMap
seems to be that samples are drawn for the random variables
1,2,3,4 and 6 and are placed in the components 1,2,3,4 and 6 of the vector that
is used as the input data for the function in the model definition and that the component no 5 in this vector is equal to 0.

Dear Olaf

First of all, welcome to UQWorld :smiley: ! I reproduced your problem and it turns out that this is indeed a bug in the current version of the inversion module - thanks for spotting it because it is quite well hidden.

The problem is not directly related to the PMap vector, but actually only occurs when constant parameters are involved (as is the case for paremeters b, h and \ell in uq_Example_Inversion_05_MultipleModels.m). In this case the inversion module removes the constants from the input object and only adds them upon model evaluation. For this, it uses the function uq_inversion_addConstants which erroneously does not consider the PMap.

We will fix this issue in the next release of UQLab. In the meantime, you can modify the source code yourself by adding a few lines in this function and the module initialization file (uq_initialize_uq_inversion) highlighted in bold font below:

  • uq_initialize_uq_inversion

    ConstInfoCurr.idConst = ModelConstInfo.idConst(discrConst);
    ConstInfoCurr.valConst = ModelConstInfo.valConst(discrConst);
    ConstInfoCurr.idFull = ModelConstInfo.idFull(discrFull);
    ConstInfoCurr.PMap = Internal.ForwardModel(ii).PMap;

  • uq_inversion_addConstants

    idConst = ConstInfo.idConst;
    valConst = ConstInfo.valConst;
    idFull = ConstInfo.idFull;
    PMap = ConstInfo.PMap;

    %%Assign to xAug
    xAug(:,idFull) = x; %% Variable parameters
    xAug(:,idConst) = repmat(valConst,size(x,1),1); % Constant parameters

    % extract relevant from PMap
    xAug = xAug(:,PMap);

Again, thank you for spotting this and please let me know if this solves your problem!

1 Like

Dear Paul-Remo,

thanks you for your help. Using your fix seems to have solved the problem. I could get now the same results with the original function definition that I produced before with my emergency work around i.e. to replace in the functions in your examples X(:,5) by X(:,6).
Best regards Olaf