BesselK with the order (v) as real (parameter)

@lionel68 The PR was closed for now, but there is hope :-)

It is currently out of my short-term plan to complete this, but if there is need and will to cooperate on a final push to make it happen, then a lot of the work has been done. If you read the comments on the PR (start at the end) you’ll notice that there is a remaining part of the parameter space where the code has large error. This needs to be resolved if the code is to be included in the main codebase and I ran out of ideas. The computation is also very much slow.

If you don’t care about this part of the parameter space I have adapted, a slightly older version of the code to work as a custom C++ function in Stan, so you can use it right away: https://github.com/stemangiola/RNAseq-noise-model/blob/SICHEL-reparametrised/dev/besselk.hpp (attribution would be nice)

To use it, have

functions {
  real log_besselk_frac(real v, real z);
}

in your stan file and compile the model with

includes = '\n#include "besselk.hpp" \n'
2 Likes