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!
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
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.
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[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…
Thanks!
I wrote an implementation of the algorithm Ben Goodrich linked above here: GitHub - szego/truncated-student-t-rng
The function n_t_q(z, nu)
defined in this Stan code is an approximation for F_inv(G(z)), where G is the CDF of the standard normal distribution and F_inv(p) is the quantile function for the t distribution.
Cool! I also coded up the R student t qf in Stan last year. It’s at Student_t quantile function if you want to test it as well.