BAMresearch / bayem

Implementation and derivation of "Variational Bayesian inference for a nonlinear forward model." [Chappell et al. 2008] for arbitrary, user-defined model errors.
MIT License
2 stars 1 forks source link

Bivariate quantiles #94 #95

Closed TTitscher closed 2 years ago

TTitscher commented 2 years ago

visualize_vb_marginal_matrix now takes a contour_quantiles=np.r_[0.5, 0.7, 0.9] argument and visualizes only those quantiles in the bivariate coutours.

The calculation of the actual levels is done numerically based on the 2d probability matrix (already used for the contour plot itself). First, a range of probabilities level_range is defined and for each level the entries larger than this level are summed up. Divided by the total sum, this gives the quantile for that level. Those values are then interpolated to the user defined contour_quantiles.

As @joergfunger pointed out, there is an analytic formula for the case of bivariate normals. The numeric approach is also valid for Gamma/Gamma or Gamma/Normal, and it is "only" for the plot. So if the line is two or three pts off, it should not really matter.