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

Visualization of marginalized posteriors #94

Open joergfunger opened 2 years ago

joergfunger commented 2 years ago

In the visualization, pair plots are created that plot on the diagonal the marginal distributions and on the off-diagonal elements the bivariate marginal distributions. The plot distinguishes between 2 normal variables (related to parameters in the model) and the other cases assumed to be uncorrelated.

  1. It would be nice to prescribe quantiles to isolines to be plotted. For the bivariate normal this is e.g. alpha/(sqrt((2*pi)**2 det(cov_2). See e.g. this link with alpha the quantile, and then substituting this in the bivariate pdf to obtain the isolines, i.e in visualize_vb_marginal_matrix this might be added with dist being the bivariate marginal normal posterior of the two variables
    levels = (1/ np.sqrt((2 * np.pi) ** 2) / np.linalg.det(dist.cov)) *np.atleast_1d(alpha)
    axes[i, j].contour(xj, xi, pdf, colors=[color], linewidths=lw,  levels = levels)
  2. For the case with two correlated noise terms, the assumptions of just multiplying the two univariate gamma pdf seems not correct, since they are actually correlated.
  3. For the case of a normal distributed model parameter and a gamma distributed noise precision, the plot seems not correct, since these are currently ellipsoids, but for gamma being non-symmetric I would expect a non-symmetric joint pdf.
joergfunger commented 2 years ago

The merge request has solved 1, 3 might be actually correct and for the example I looked into the gamma distr. was close to a normal distribution, but 2 is still unresolved, correct?

TTitscher commented 2 years ago

Due to the mean field approximation in VB, all noise groups are independent. Only model parameters can be correlated.

joergfunger commented 2 years ago

True, I somehow thought that the noise terms are also correlated (thus in a single noise group), but I think that is wrong and all noise are a supposed to be uncorrelated.