I haven’t had a chance to use the unnormalized _lupmf and _lupdf’s yet, but I noticed them in the documentation and was curious of the exact definitions of them. The documentation is a little vague on them currently and I couldn’t find the location of the code on github.
I bring this up because the documentation [1] has an example for the normal_lupdf that I found interesting. I noticed it dropped both the pi terms as well as the log of the standard deviation. I had not expected that and wanted to check out what else was different from what I would have expected.
[1] 22.1 Dropping Proportionality Constants | Stan User’s Guide
Note that in the example, sigma
is declared as data. If sigma
is a parameter, this won’t be dropped. This flexibility makes a concise definition of these functions a bit cumbersome, because what gets dropped depends on which inputs are parameters. I don’t know if this is helpful, but here the C++ where it all happens
3 Likes
Interesting. Thanks a lot! I kept searching or normal_lupdf, didn’t think to search for normal_lpdf.
The difference is that an _lupdf call sets the template argument propto
to true
while the _lpdf call sets it it false
. Those include_summand<>
s check if the inputs are data or parameters (i.e. autodiff types).
3 Likes
I noticed that, without exactly knowing what include_summand
did exactly. What does propto
stand for?
I’ll also add that the exact values of _lupmf
can change between Stan versions, as e.g. the reordering of operations I did for negative binomial at More stable implementation of neg_binomial_2_log_lpmf by martinmodrak · Pull Request #1830 · stan-dev/math · GitHub means that different part of the computation are now constant in some cases. So once again exact definition can be a problem.
3 Likes