Log of modified_bessel_first_kind

This guy has it GitHub - tk2lab/logbesselk: Provide function to calculate the modified Bessel function of the second kind and its derivatives.. I tried porting to R but I wasn’t able to get the same answers.

1 Like

@Bob_Carpenter @spinkney @andrjohns

Thank you for the reply.

I gather Bessel functions with real order are hard to implement. I think I will have to wait for 1F1 or 0F1 to get implemented.

Thanks for the reminder! The PR for the pFq gradient calculations should be merged soon, once that’s in I’ll be adding the remaining hypergeometric functions from Boost

2 Likes

Hi @andrjohns ,

Thank you so much for working on this. I really appreciate it.

I am working on two projects where pFq turns up. One on N-mixture models that uses pFq and one on local adaptation which uses 1F1. It would be extremely helpful to have both pFq and 1F1 functions. I wrote my own implementation here, but they are very slow.

If you are looking for a case study that uses pFq, I can provide my code on the N-mixture model. These models are widely used in ecology. Having native implementation of pFq and grad_pFq in Stan would speed up these models by orders of magnitude.

2 Likes

Hi @andrjohns
I saw that the grad_pFq just got merged. Can I request that 1F1 or 0F1 functions be available for users in the next release? I completely understand if you do not have time to get these functions in time.

In my postdoc project, I call these functions 5 million times. My current implementation of the function as a truncated power series gets the job done but only works on 1/25th of the dataset, even after running the model on a cluster using map_rect.

Thank you so much for your time.