They’re pretty much identical if you look at how a 2-dimensional simplex gets implemented.
-
You don’t need to write down
dirichlet([1, ..., 1])
orbeta(1, 1)
explicitly because they’re uniform and don’t add anything other than a constant to the log density. -
Stan’s underlying simplex implementation (see the transforms chapter of the reference manual), does exactly what you’ve coded—give
delta[1]
auniform(0, 1)
distribution and then setdelta[2] = 1 - delta[1]
.
Also, you can just try both and see if there’s a speed difference you can detect (you can’t define beta the way you did—it needs two real-valued arguments, not a vector argument). It’s often hard to figure out what the C++ optimizer is going to do and sometimes things that look like the same code can have different performance. I don’t expect that here though.