Student T cumulative distribution function

I wonder if there is a quantile function for t-distribution, similar to inv_Phi(). If not, is there any trick that I can use to generate such a quantile function?


For what degrees of freedom?

fixed. 7.3

There is nothing in Stan. The best algorithm is probably in section 3 of

1 Like

Thanks! Looks complicated …


This may be silly, but Is it possible for me to define such a function in Stan, by taking advantage of integrate_id() and gamma()?

Yes, and algebraic_solver if you need the inverse CDF.

1 Like

I tried algebra_solver to get inverse CDF of t distribution

vector algebra_system(vector y, vector theta, real[] x_r, int[] x_i){
vector[1] solution;
solution[1] = student_t_cdf(y[1], theta[1], 0, 1) - theta[2];
return solution;

data {


transformed data {
vector[1] y_guess=[0]’;
real x_r[0];
int x_i[0];
real rel_tol = 1e-8;
real f_tol = 1e-4;
real max_steps = 1e5;

parameters {


transformed parameters {
for (i in 1:N) {
vector[2] theta;
theta[1] = nu;
theta[2] = mu[i];
Y[i] = algebra_solver(algebra_system, y_guess, theta, x_r, x_i, rel_tol, f_tol, max_steps)[1];

model {


Do you think I have coded algebra_solver correctly or efficiently? I got no error message, but the sampling is very very slow…