# 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?

Thanks!

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

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

data {

}

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

parameters {

}

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

model {

}

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

Thanks!