We have the following signatures:
real dirichlet_lpdf (vector theta | vector alpha)
vector dirichlet_rng (vector alpha)
I would expect them to instead be:
real dirichlet_lpdf (simplex theta | vector alpha)
simplex dirichlet_rng (vector alpha)
Is this due to some performance concerns or technical limitations within the C++ implementation?
More about performance concerns. We do test our inputs satisfy relevant constraints in our lpdf functions (e.g., theta
is a simplex with the same number of entries as the positive vector alpha
for dirichlet_lpdf(theta | alpha)
. But we didn’t want to have declared constrained types as it would imply some kind of constraint checking on user-defined functions. For local variables, it wasn’t clear when the check would be carried out and for the function arguments, the checks would often be redundant (in that the user is guaranteeing the constraint is satisfied, so you don’t want to check again on general principles).
Underlyingly, in Stan’s C++, vectors are all Eigen::Vector
types no matter what their constraints (ordered, simplex, unit, upper and/or lower bound, etc.).