# Effect of PMap: Documentation and Implementation seem do differ

**URL:** <https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618>\
**Category:** Community Q&A and How To\
**Tags:** inversion\
**Created:** [May 26, 2020, 5:00pm UTC](https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618 "2020-05-26T17:00:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![olaf.klein](https://uqworld.org/user_avatar/uqworld.org/olaf.klein/32/468_2.png) [@olaf.klein](https://uqworld.org/u/olaf.klein)\
**Post date:** [May 26, 2020, 5:00pm UTC](https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618/1 "2020-05-26T17:00:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paulremo](https://uqworld.org/user_avatar/uqworld.org/paulremo/32/192_2.png) [@paulremo](https://uqworld.org/u/paulremo)\
**Post date:** [May 27, 2020, 8:21am UTC](https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618/3 "2020-05-27T08:21:36Z")

</div>

Dear Olaf

First of all, welcome to UQWorld 😃 ! 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`

- `uq_inversion_addConstants`

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

---

<div class="post-metadata">

**Author:** ![olaf.klein](https://uqworld.org/user_avatar/uqworld.org/olaf.klein/32/468_2.png) [@olaf.klein](https://uqworld.org/u/olaf.klein)\
**Post date:** [May 27, 2020, 3:22pm UTC](https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618/4 "2020-05-27T15:22:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![damarginal](https://uqworld.org/user_avatar/uqworld.org/damarginal/32/73_2.png) [@damarginal](https://uqworld.org/u/damarginal)\
**Post date:** [June 1, 2020, 6:31pm UTC](https://uqworld.org/t/effect-of-pmap-documentation-and-implementation-seem-do-differ/618/5 "2020-06-01T18:31:05Z")

</div>


