Let \(W\) denote a random variable with standard normal distribution that is \(N(0, 1)\); let \(V\) denote a random variable that is \(\chi^2(r)\); and let \(W\) and \(V\) be independent. Then the joint pdf of \(W\) and \(V\) ,say \(h(w, v)\), is the product of the pdf of \(W\) and that of \(V\) or \[ h(w,v)=\begin{cases} \frac{1}{\sqrt{2\pi}}e^{-w^2/2}\frac{1}{\Gamma(r/2)2^{r/2}}v^{r/2-1}e^{-v/2}, & \text{$-\infty>w<\infty, 0<v<\infty$}.\\ 0, & \text{elsewhere}. \end{cases} \]
Define a new random variable \(T\) by writing
\[T=\frac{W}{\sqrt{V/r}}\]
We use the following transformation: \[ t=\frac{w}{\sqrt{v/r}} \quad \text{and } u=v\] then the Jacobian is
\[|J|=\begin{vmatrix} \frac{\partial w}{\partial t} & \frac{\partial w}{\partial u}\\ \frac{\partial v}{\partial t}& \frac{\partial v}{\partial u} \end{vmatrix}=\frac{\sqrt{u}}{\sqrt{r}}\]
The joint pdf of \(T\) and \(U\) is given by
\[g(t,u)=h(\frac{t\sqrt{u}}{\sqrt{r}},u)|J|=\frac{1}{\sqrt{2\pi}}e^{-\frac{(t\sqrt{u/r})^2}{2}}\frac{1}{\Gamma(r/2)2^{r/2}}u^{r/2-1}e^{-u/2}\frac{\sqrt{u}}{\sqrt{r}}\\= \frac{1}{\sqrt{2\pi}}\frac{1}{\Gamma(r/2)2^{r/2}}u^{r/2-1}e^{-\frac{(t\sqrt{u/r})^2}{2}}e^{-u/2}\frac{\sqrt{u}}{\sqrt{r}}\\= \frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}u^{r/2-1}u^{1/2}e^{-\frac{t^2u/r}{2}-u/2}\\= \frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}u^{(r+1)/2-1}\exp\left[-\frac{u}{2}(1+\frac{t^2}{r})\right] \]
The marginal pdf of \(T\) is
\[g_1(t)=\int_{-\infty}^{\infty}g(t,u)du=\int_{0}^{\infty}\frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}u^{(r+1)/2-1}\exp\left[-\frac{u}{2}(1+\frac{t^2}{r})\right]du \tag{1}\]
Next let \(z=\frac{u}{2}(1+t^2/r)\) then \(u=\frac{2z}{1+t^2/r} \tag{2}\)
Plug \((2)\) into \((1)\) and we get
\[g_1(t)=\int_{-\infty}^{\infty}g(t,u)du=\int_{0}^{\infty}\frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}(\frac{2z}{1+t^2/r})^{(r+1)/2-1}e^{-z}\frac{2}{1+t^2/r} dz\\= \int_{0}^{\infty}\frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}(\frac{2}{1+t^2/r})^{(r+1)/2-1}z^{(r+1)/2-1}e^{-z}\frac{2}{1+t^2/r}dz\\= \int_{0}^{\infty}\frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}(\frac{2}{1+t^2/r})^{(r+1)/2}z^{(r+1)/2-1}e^{-z}dz\\= \int_{0}^{\infty}\frac{1}{\sqrt{2\pi r}}\frac{1}{\Gamma(r/2)2^{r/2}}\frac{2^{(r+1)/2}}{(1+t^2/r)^{(r+1)/2}}z^{(r+1)/2-1}e^{-z}dz\\= \frac{1}{\sqrt{\pi r} \times \Gamma(r/2)(1+t^2/r)^{(r+1)/2}}\int_{0}^{\infty}z^{(r+1)/2-1}e^{-z}dz\tag{3} \] Now we try to make the integrand at the last step of \((3)\) as a \(\Gamma\) pdf
Then \[g_1(t)=\frac{\Gamma[(r+1)/2]}{\sqrt{\pi r} \times \Gamma(r/2)(1+t^2/r)^{(r+1)/2}}\int_{0}^{\infty}\frac{1}{\Gamma[(r+1)/2 ]\times 1}z^{(r+1)/2-1}e^{-z}dz \tag{4}\]
Note in \((4)\) the integrand is a \(\Gamma\) pdf with \(\alpha=\frac{r+1}{2}\) and \(\beta=1\)
Therefore, \[g_1(t)=\frac{\Gamma[(r+1)/2]}{\sqrt{\pi r} \times \Gamma(r/2)(1+t^2/r)^{(r+1)/2}}\]
This is the pdf for the random variable \(T\) i.e the pdf for the Student \(t\) distribution.