To do that in Stan you'd need to define functions for all the
complex operations and treat the vector as a 2 x N vector with
a real and imaginary component. Then you could write that recursive
equation (you'd need a base case, though!).
I don't know that it'll be easier to do in C++. The point is
that Stan's going to need gradients with respect to all the parameters
and expects a templated functor it can automatically differentiate,
which means something implemented with our library of functions where
the partials are known.
If you define the functions in Stan, this'll all happen automatically,
by the way.
- Bob
> On Apr 18, 2015, at 2:22 AM, Dennis Conway <
denni...@gmail.com> wrote:
>
> Hey Daniel, thanks for your help on this.
>
> I think it would be quite tricky to split up the imaginary and real parts into two parameters, as there are a few multiplications in my formula which I would need to write in terms of stretchings and rotations. The calculation involves a recursive formula, which I've put at the bottom of this message, and the probability is given by a misfit between the output of the recursive formula and some data that I have. If this is straightforward enough to write up in C++ then I will have a go at it, as I'm curious to see how my model (high dimensionality with highly correlated parameters) performs with the NUTS sampler.
>
> Thanks,
> Dennis
>
> t is real
> c&q are complex valued
> c_{n} = \frac{c_{n-1}\cdot q_{n}+\tanh(tq_{n})}{1+c_{n-1}\cdot q_{n}\cdot \tanh(tq_{n})}\frac{1}{q_{n}}
>