How to save logp values during sampling?


I asked a similar question here, but this time I’d like know if there’s a way to add the logp values of accepted points to the trace as we sample, so that we don’t have to evaluate it twice?

Frequently Asked Questions

You are asking some great questions :wink: These should go into our docs I think…
There is two way to do it, the easiest is to create a Deterministic RV to save the logp. This is what we do in SMC currently:

A more complicated way is to put the logp into the sampler statistics of the trace, there is a discussion here: