What does the propto template argument do?

I’m looking at some lpdf functions in the stan math library and there is a template type <bool propto, ...> which isn’t described in the doxygen documentation. It seems required since at compilations, lpdf functions are called using the argument

std_normal_lpdf<false>(...);

so I’m guessing the false is the propto argument here, which gets used in include_summand – not sure what this does.

If my memory is correct it was related to dropping all constants (edit). Not dropping was the default, <false>. propto is from proportional to, I guess?

That is correct.

The sampling statement (tilde form) or the use of the _lupdf suffix will use propto=true, while target += …_lpdf will use propto=false.

Ok, this makes sense. I guess this is a recent addition? I didn’t need it in previous lpdf and lpmf functions I implemented, though I agree this feature makes sense.

@rok_cesnovar Are we dropping all constants (including \log (\sqrt{(2 \pi)} for normal for instance) or only the constants resulting from constrained to unconstrainted transformation? If the former is correct, which I am leaning towards, I would have to edit my first post.

This has been a part of Stan Math as long as I can remember and is also mentioned in the Stan Math paper so I would guess it was there from the start. If a lpdf/lpmf function does not use the propto argument, it would just be ignored I guess.

Quickly grepping through the lpdf/lpmf function I cant find any without the propto bool.

All constants. See this line: https://github.com/stan-dev/math/blob/002590e0f44687da57daf6cdddd605f774270aee/stan/math/prim/prob/normal_lpdf.hpp#L84

1 Like

Lol. My bad then