# Bayesian calibration for dynamic parameters of dam

**URL:** <https://uqworld.org/t/bayesian-calibration-for-dynamic-parameters-of-dam/1205>\
**Category:** Community Q&A and How To\
**Tags:** pce, inversion\
**Created:** [May 28, 2021, 5:40am UTC](https://uqworld.org/t/bayesian-calibration-for-dynamic-parameters-of-dam/1205 "2021-05-28T05:40:35Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [June 7, 2021, 11:32am UTC](https://uqworld.org/t/bayesian-calibration-for-dynamic-parameters-of-dam/1205/14 "2021-06-07T11:32:03Z")

</div>

Dear felix,

I think that there are some UQLab featrues that may help you out of the box, but I am not sure if they  
are sufficient for you.  
One remark in advance.:  
It holds in both for your files that your settings for `Solver` are **not copied** to `BayesOpts.Solver` at the end (see UQLab Manual 3.1.4) such that all your settings are ignored at the end and the default values are used. This can be seen for example in the trace plots above ending after 300 steps.

1. If you want, for example, compare the prior and posterior density for E1, you can use the commands

```matlab
% Using the default value of BayesOpts.Solver.MCMC.Steps being 300, the
% default value of BayesOpst.Solver.MCMC.NChains being 100 for the default 
% AIES-MCMC scheme and the default value of 0.5 for burnIn there are 151
% steps in myBayesianAnalysis_surrogateModel.Results.PostProc.PostSample 
% each with 100 values, i.e. there are 15100 samples values for the posterior 
% densithy that are provided as input data to the plot function. To get plots 
% that can be compared, we need a similar number samples for the prior 
% that are generated by the following call of uq_postProcessInversion
% Attention: In the following line there was an incorrect 5000 in the original version of this post
 uq_postProcessInversion(myBayesianAnalysis_surrogateModel,'prior',15100);
uq_display(myBayesianAnalysis_surrogateModel,'scatterplot',1)

```

leading to two figures similar to  
 ![density-prior-E1](https://uqworld.org/uploads/default/original/1X/48d96b3001dc6e20f151ebef1c67237029a48985.png)

and  
 ![density-post-E1](https://uqworld.org/uploads/default/original/1X/c7aadfa12e6d3a2b9f83ef794c338b2e5626a753.png).

1. In the original UQLab 1.4.0 version of `uq_display_uq_inversion.m` the limits for the plots for the posterior density are determined from the limits for the plots for prior density, see [my topic to this behavior](https://uqworld.org/t/uq-display-uq-inversion-determine-limits-for-scatter-plots-for-posteriori-samples-from-the-posteriori-samples-instead-of-using-prior-samples/1141). Hence, you can use these plots to compare prior and posterior densities.

2. In view of the plots above your may need more samples for both densities to get nice plots for both densities.

3. I would not be surprised if there are MATLAB methods to combine the two figures created by `uq_display` via calling `uq_display_uq_inversion` somehow after you managed to get the handles for them but this is beyond my MATLAB skill.

4. An other way to get one plot with prior and posterior density is (after following step 3) to copy the contents of `myBayesianAnalysis_surrogateModel.Results.PostProc.PriorSample` and of  
`myBayesianAnalysis_surrogateModel.Results.PostProc.PostSample`, following the [instructions by Paul-Remo to rearrange the copy of `....PostSampe`](https://uqworld.org/t/looking-for-documentation-example-of-using-uqlab-results-of-bayesian-inference-for-forward-uq-or-further-bayesian-inference/690/2) and use afterwards the MATLAB command `histogram` to generate a plot with histograms for both data sets.

Greetings  
Olaf

---

_[View the full topic](https://uqworld.org/t/bayesian-calibration-for-dynamic-parameters-of-dam/1205)._
