Hi, I have just recently started using Stan and currently I am trying to write a C++ lpdf function for the von MIses-Fisher 2D spherical distribution function. I am learning by looking at the example of writing an lpdf function of normal distribution as provided in this document (https://arxiv.org/abs/1509.07164). In the normal_lpdf.hpp source (https://github.com/stan-dev/math/blob/37f1d0916f50185601ad18aa995ef6f42bf52966/stan/math/prim/prob/normal_lpdf.hpp) I can understand that the following lines represent the log probability density function as shown by equation (1) on page 3 of the document:
if (include_summand<propto>::value) {
logp += NEG_LOG_SQRT_TWO_PI;
}
if (include_summand<propto, T_scale>::value) {
logp -= log_sigma[n];
}
logp += NEGATIVE_HALF * y_minus_mu_over_sigma_squared;
I don’t understand the purpose of the following lines:
if (include_summand<propto>::value) {
if (include_summand<propto, T_scale>::value) {
From this page (https://mc-stan.org/math/d1/dda/structstan_1_1math_1_1include__summand.html) it says include_summand
“calculates whether a summand needs to be included in a proportional (log) probability calculation.” This explanation is not very clear to me.
Can anyone explain them to me using the normal lpdf function as an example? If you can point me to a document that provides similar examples of include_summand
usage, it would be great too. Thanks!