Uq_display_uq_inversion: Determine limits for scatter plots for posteriori samples from the posteriori samples instead of using prior samples (at least, if there no prior samples)

Dear @paulremo , dear all,

In UQLab 1.4, the values given as parameter for 'Limits' limits are no longer ignored by the function uq_scatterDensity, such that the values in the corresponding calls to this function in uq_display_uq_inversion are now used during the creation of the scatter plot.

I am not sure, if this is a planed behavior or an error, but it holds that the limits for the scatter plots for the prior samples and for the posterior sample are both computed from the prior samples. In UQLab 1.3 these values were ignored by uq_scatterDensity, but this is no longer the case in UQLab 1.4, as one can observe e.g. by considering the scatter plots in the 1.4.version of UserManual_Bayesian.pdf. In these plots, the plot ranges in the prior plot and in the posterior plots are the same, see also my version of the scatter plots in Figure 9:
fig-9-scatter-prior
fig-9-scatter-posterior-org

I do not like this same plot limits approach, since the variation of the posterior samples
(after removing the burn-In phase and maybe also bad chains) may be much smaller then the
variation of the prior samples and are invisible in plots using the limits determined from
the prior samples. Therefore, I have replaced in my copy of uq_display_uq_inversion.m
in the line 297 allPlotPoints = [PriorSample; plotPointCollection]; by allPlotPoints = [PostSample; plotPointCollection];. Thanks to this modification, the resulting scatter plot for the posterior samples changed to

fig-9-scatter-posterior

In contrast to the posterior scatter plot above, one can really see the variation of E.

Hence, I suggest to perform this change also in the official version of uq_display_uq_inversion and to replace in line 314 'Limits', [min(PriorSample);max(PriorSample)],... by
'Limits', [min(PostSample);max(PostSample)],... .

If this same plot limits approach behavior is planed, I would suggest to add to the flags considered in Further plot possibilities for results of Bayesian inversion (Suggestions and code example) - #2 by paulremo a flag like ‘scatter.reusePriorlimits’ that allows to activate/ deactivate this approach.

Greetings
Olaf

1 Like

Hi @olaf.klein

This behavior is indeed on purpose to show the information gain from updating. However, I agree with you that a flag option would make more sense to allow visual inspection of the posterior distribution in cases of large information gain, like the one you mention in your post.

Can you add a reference to this post to the original post here?

Dear @paulremo, dear all,

since there no flag-option based solution has been released until now, I would like to suggest a change of uq_display_uq_inversion_MCMC.m that allows to switch between both kinds of determine plot limits by simply adapting the content of myBayesianAnalysis, i.e.the module/object being the input for ` uq_display_uq_inversion_MCMC.m, see my file uq_display_uq_inversion_MCMC.m (22.1 KB)

As long as one has a .PriorSample component in the ...Results.Postproc structure, the limits of this fields are also used to determine the boundaries for plots for the posterior samples, But, if this component does not exists, i.e. if one has performed
uq_postProcessInversion(myBayesianAnalysis,'priorPredictive',0);,
then the scatter plots for the posterior samples are adapt to the limits of this samples.

I have just replaced the line 328

 plotLimits = [min(allPlotPoints); max(allPlotPoints)];

by

 if procPriorSample_avail
       allPlotPoints = [PriorSample; plotPointCollection];
  else
       allPlotPoints = [PostSample; plotPointCollection];
  end

and 337-343

  uq_scatterDensity(...
            gca,...
            PostSample,...
            'Labels', paramLabelsScatter,...
            'Color', postColor,...
            'Limits', [min(PriorSample);max(PriorSample)],...
            'Title', 'Posterior Sample');

by

   if procPriorSample_avail
         plotLimits = [min(PriorSample);max(PriorSample)];
    else
        plotLimits = [min(PostSample);max(PostSample)];
    end
    uq_scatterDensity(...
            gca,...
            PostSample,...
            'Labels', paramLabelsScatter,...
            'Color', postColor,...
            'Limits', plotLimits,...
            'Title', 'Posterior Sample');

In this is changed, one can also create scatter plots also if no prior samples are
available. According to a remark on page 72 of the documentation this should be possible, but currently I get an error message if I try to do this.

Greetings

Olaf

1 Like

Dear @olaf.klein

Thanks for reporting this potential bug! I am no longer an active developer for UQLab, but I reported the issue to the current development team and they will have a look as soon as possible. I also informed them of the flag option you suggested to allow ignoring the prior sample limits for the posterior sample plot.

I still think this would make a nice feature, but there is a trade-off here between keeping the syntax simple and adding this feature.

1 Like

Dear @paulremo ,

thanks for your fast replay and for your all support in the past.

1 Like