function x = t_inv(p,k)
% x = t_inv(p,k)
% inverse student t cumulative distribution function with k degrees of freedom
%  p: probability value .. 0 < p < 1   k > 0                (N x M)
%  k: degrees of freedom, a positive integer,    0 < k      (1 x 1)
%  x: values of x for which the t-distribution CDF equals p (N x M)

x = (sign (p - 1/2) .* sqrt (k * (1 ./ beta_inv (2*min(p, 1-p), 0 , 1 , k/2, 1/2 ) - 1)));

% -------------------------------------------------------------------

