On 6/23/12 7:57 PM, Ben Goodrich wrote:
> On Saturday, June 23, 2012 5:23:57 PM UTC-4, Bob Carpenter wrote:
>
> All in all, though, I'm wondering how much clearer this all is
> and if it'll be easier to understand and maintain than the
> whole-bunch-of-functions approach.
>
>
> My $0.02 is that this partials stuff with metaprogramming is likely to be understood only by computer scientists with an
> above average understanding of C++.
I'm afraid that's the ante at this point.
It still helps to make things clear. I'm still confused
every time I look at Eigen, but I think that's largely
because of their use of macros more than the C++ itself.
> But, it seems that it would substantially lower the barriers to entry for a typical
> statistician who might be able to add a new density to stan. So, even if there is no net improvement in speed or no net
> improvement in maintainability, I think if there is a gross improvement on a dimension where a larger pool of people
> might be interested in contributing to stan, that is a good thing in the long term.
This is mainly going to matter in the case where someone
wants to unfold the derivative calcs rather than using
auto-diff. It makes a big difference in speed.
At that point, we have a coding style in play that'll
make it pretty clear in a way rather like the Rcpp interface
to the R data structures:
1. pull values out in double-based scalars, vectors, etc.
using value_of() function.
2. compute log probability and derivative, dropping terms
based on include_summand<> metaprograms and dropping
gradient terms based on is_constant<>.
3. return by calling something like simple_var(value,y,dy,mu,dmu,sigma,dsigma);
[that function needs a better name, like partials_var].
What we're talking about now is mostly about how to
save ourselves a combinatorial explosion in writing
simple_var() and the underlying support class in the
face of variable/double/vector of variable/vector of double,
etc. arguments.
- Bob