Compute the KL divergence between two distributions

I think I have at least partial answers to my questions for those who have the same one?

  1. The logp methods operate on points, so we can do things like this:
    model.logp(posterior_trace.point(i)).item() for i in range(X)
  1. For this I was interested in comparing results from a prior and a posterior model. So if I have a model constructor that optionally takes observations as arguments, I believe I can do the following:
    a. Create a prior model, m1
    b. Create a posterior model m2 that is like m1, but has some observed variables.
    c. AFAICT the points from a trace generated by either m1 or m2 can be evaluated using the logp method of either model. Indeed, if I understand @junpenglao 's argument elsewhere, the logp of these two models will be identical, and the only difference between the two will be in the normalizing constant (the logp being in general an un-normalized potential, instead of a probability).
1 Like