> On Apr 21, 2015, at 9:22 PM, Christopher Steele <
steele...@googlemail.com> wrote:
>
> I had a go at this but it doesn't seem to have worked. I downloaded the stan source files from your github, and linked to the eigen and boost libraries when compiling my model using the Rstan function stan(), but I still get the tgamma errors when I run my model.
I'm not sure what you were trying. That function's just what gets called
in a Stan program.
>
> So instead I have been looking into coding up a log gamma cdf function in C++. I read on another mailing list post that any functions you use in C code has to be understood by autodiff. Does this mean I cannot use binary arithmetic, break statements and the like?
Break statements are fine. By binary arithmetic, you mean bit fiddling like the
binary | and & or << and <<< shift operations?
The trick is that any functions or operations that are involved in the result
have to be auto-diffable. So if you bit fiddle to do something like choose which
iterative algorithm to run, that'll probably be OK, but you'll have to be careful
in how you pull the bits out.
We're happy to advise if you have something specific in mind, like a stable
C++ algorithm that works on double values that you just want to translate to
something that can be autodiffed.
And it's no holds barred if you implement custom derivatives for the code. I think
you'll find the problem is that there's not a very big range through which CDFs can
be autodiffed due to floating point representations themselves (that is, they don't
have enough range to represent the derivatives in many cases).
> Or are there functions that autodiff understands, but are not included in the stan manual?
Nope --- they're all in the manual. But control's separate --- you can use
the regular loops, while, conditionals, etc., the ternary operator, etc. You just
can't import a third-party library and use its functions.
- Bob