Add student_t_qf
Description
With the incorporation of inv_inc_beta from pr #2637 it is easy to add. Will follow the organization of the files from the std_normal_qf pr #2744
Example
student_t_qf(real u, real nu)
student_t_qf(real u, vector nu)
student_t_qf(real u, array[] real nu)
student_t_qf(vector u, real nu)
student_t_qf(vector u, vector nu)
student_t_qf(vector u, array[] real nu)
student_t_qf(array[] real u, real nu)
student_t_qf(array[] real u, vector nu)
student_t_qf(array[] real u, array[] real nu)
// implementation is simple
student_t_qf(real u, real nu) {
real x = u < 0.5 ? 2 * u : 2 * (1 - u);
return sign(u - 0.5) * sqrt( nu * (1 / (inv_inc_beta(nu / 2, 0.5, x))) - 1);
}
// where
// inv_inc_beta(a, b, p)
// * @param a Shape parameter a >= 0; a and b can't both be 0
// * @param b Shape parameter b >= 0
// * @param p Random variate. 0 <= p <= 1
I believe I can wrap the qf from boost. They say that the method is faster than using the inv_inc_beta implementation above. You can see the comment in boost at https://github.com/boostorg/math/blob/b2538faaf9802af8e856c603b9001e33db826676/include/boost/math/distributions/students_t.hpp#L251.
However, I need to add the derivatives. Luckily, the 2nd value of the inv_inc_beta is a constant. I can reuse the implementation that is already in stan-math for that part. The method above can be auto-diffed through to test my implementation.