Transform Student's T distribution to Beta distribution I want to calculate the inverse CDF of the Student's T distribution, but I only have an accurate routine for the Beta distribution available. I have tried to make a transformation, but I'm getting the wrong answers out. Could somebody check my reasoning?
Let $T$ have a Student's $T$ distribution with $n$ degrees of freedom. Given a probability $p$, we want to find $t$ such that
$$
P(T < t) = p
$$
Let us suppose without loss of generality that $t \geq 0$, i.e. $p \geq 1/2$, since otherwise we can use symmetry to frame the problem this way. First, we transform to a $F_{1,n}$ distribution:
$$
P(T < t) = 1 - P(T > t) = 1 - \frac{1}{2} P(|T| > t) = \frac{1}{2} \left( 1 + P(|T| < t) \right) = \frac{1}{2} \left( 1 + P(T^2 < t^2) \right)
$$
Noting that $T^2$ is distributed as $F_{1,n}$ (see here), we can rearrange to get:
$$
P(F_{1,n} < t^2) = 2p - 1
$$
Next we use the fact that if $B$ has a $Beta(\frac{\alpha_1}{2}, \frac{\alpha_2}{2})$ distribution, then $\frac{\alpha_2 B}{\alpha_1 (1 - B)}$ has an $F_{\alpha_1, \alpha_2}$ distribution (see here), to transform our expression (with $\alpha_1 = 1, \alpha_2 = n$):
$$
P \left( \frac{nB}{1 - B} < t^2 \right) = 2p - 1 
$$
We use $B > 0$ to rearrange the inequality:
$$
P \left( B < \frac{t^2}{n + t^2} \right) = 2p-1
$$
Letting $F_B$ be the CDF of $B$, we set $x = F_B^{-1}(2p - 1) = \frac{t^2}{n + t^2}$ and we can solve the original problem for t:
$$
t = \sqrt{ \frac{xn}{1 - x} }
$$
Where the positive square root is taken because of our assumption that $t > 0$. Is this correct?
 A: Yes, your approach is generally correct if you want to generate realizations of a Student's $t$-distributed random variable $T$ from a suitable Beta-distributed random variable $X$.  You would presumably use a third, auxiliary random variable, say $Y \sim \operatorname{Bernoulli}(1/2)$; e.g.,
$$X \sim \operatorname{Beta}(1/2, n/2), \quad Y \sim \operatorname{Bernoulli}(1/2), \\ T = (2Y-1) \sqrt{\frac{nX}{1-X}} \sim \operatorname{StudentT}(n).$$
The reason for the additional Bernoulli variable is so that you can generate negative realizations of $T$, not just the positive ones.
While your derivation employs the "inverse CDF" method, this doesn't actually yield a closed-form inverse CDF for the Student's $t$ distribution, since there isn't a simple closed form for the inverse of the beta CDF.  It only shows how, if you have access to a random number generator that can generate realizations from a beta distribution, you can use it to get Student's $t$ realizations via a simple transformation.
