How define generalized inverse gaussian distribution

Hi, I am trying to define generalized inverse-Gaussian distribution, but it needs the use of modified Bessel of third kind function. I tried to define the Bessel of third kind function by creating an integrating function, but it takes a very time for running. Does anybody know an alternative method to implement this distribution in Stan?

The modified Bessel function of the third kind and the modified Bessel function of the second kind are the same thing, but only the latter is implemented in the Stan language and does not work for unknown orders.


I am using the density function of the GIG distribution with real order, but the Stan’s modified Bessel second kind function uses integer order. So, is there an easy way to apply this Bessel function with real orders?

No. You can marginalize over a finite set of integer orders, but that is not really the same thing.