Inverse incomplete gamma function in stan?

Is there an inverse lower incomplete gamma function in Stan? Something like inv_gamma_p(real a, real z)?

There isn’t a built-in function, and there is no closed form way to write its equation, but, if you need it for a distribution, the reciprocal of a gamma random variable is an inverse gamma random variable. As such, it appears that you can use a transform or change of variable to sample from an inverse gamma distribution, while taking advantage of this fact:

“The lower incomplete gamma function looks a LOT like the definition of the cumulative distribution function (CDF) of the gamma distribution. The only difference is that the maximum value of a CDF is unity whereas the maximum value of the lower incomplete gamma function is Γ(α). Thus, Γ(α) is a constant scale factor that relates the lower incomplete gamma function and the CDF of the gamma distribution.”

Note: this was a bit involved to find a workaround for, so I’d appreciate someone else looking this over and confirming that it’s useful