Complex normal distribution


#1

Dear All, Please help! I am new to Stan and I am hoping that it will be possible for me to use Stan for modelling complex pairs of eigenvalues. I am a first year PhD student with limited knowledge of Statistics and I am hoping that it is possible to specify complex numbers in Stan. Please could you tell me if I could do this? I have an algorithm that is written in MATLAB using a Gibbs sampler which samples from the complex normal distribution. Please could you tell me if there is any hope of being able to translate this into Stan?

Thank you, Chloe


#2

Not much. The Stan language does not support complex numbers, so the best you could possibly do is have separate vectors for the real and imaginary parts of the complex eigenvalues. But the Stan Math library does not support autodifferentiation of complex eigenvalues. There are (or were) two branches to implement autodifferentiation of complex numbers, one of which works in forward and reverse mode and the other works in reverse mode only and neither are getting merged. So pretty much the only option at this point is to write C++ functions that take matrices (of unknowns), coerce them to double, handle the complex eigenvalues, calculate the log-kernel, and attach the gradient with respect to the unknowns analytically using the precomputed_gradients function in Stan Math.