User:Beakerboy/sandbox1

The studentized range is defined as $$q=\frac{\sqrt{n} r}{\sqrt2 S}$$. To create the studentized range PDF, we will need to integrate over all combinations of a range distribution, and the $$\chi$$ distribution which would give a value of q. The range distribution is:
 * $$f(r;k)=k(k-1)\int_{-\infty}^\infty f(u-r)f(u) \left[F(u)-F(u-r)\right]^{k-2} \, \text{d}u$$

The f and F are the averages of n standard normal variables, which is $$f(z)=\sqrt n\phi(\sqrt n z)$$, and $$F(z)=\phi(\sqrt n z)$$. This gives us:
 * $$f(r;k)=k(k-1)\int_{-\infty}^\infty \sqrt n\phi(\sqrt n (u-r))\sqrt n\phi(\sqrt n u) \left[\Phi(\sqrt n u)-\Phi(\sqrt n (u-r))\right]^{k-2} \, \text{d}u$$

if $$t=\sqrt{n}u$$ then $$\text{d}t=\sqrt{n}\text{d}u$$
 * $$f(r;k)=k(k-1)\sqrt n\int_{-\infty}^\infty \phi(t-\sqrt n r)\phi(t) \left[\Phi(t)-\Phi(t-\sqrt n r)\right]^{k-2}\text{d}t$$

Combining this with the $$\chi$$ distribution gives:
 * $$f(q;k,\nu)=\frac{1}{2^{\frac{\nu}{2}}\Gamma\left(\frac{\nu}{2}\right)}\int_0^\infty x^{\frac{\nu}{2}-1} e^{-\frac{x}{2}}k(k-1)\sqrt n\int_{-\infty}^\infty \phi(t-\sqrt n r)\phi(t) \left[\Phi(t)-\Phi(t-\sqrt n r)\right]^{k-2}\text{d}t\text{d}x$$

or
 * $$f(q;k,\nu)=\frac{1}{\sqrt2^\nu\Gamma\left(\frac{\nu}{2}\right)}\int_0^\infty \sqrt{x}^{\nu-2} e^{-\frac{x}{2}}k(k-1)\sqrt n\int_{-\infty}^\infty \phi(t-\sqrt n r)\phi(t) \left[\Phi(t)-\Phi(t-\sqrt n r)\right]^{k-2}\text{d}t\text{d}x$$

Since x in the $$\chi^2$$distribution is defined as $$x=\nu S^2$$ we can set $$y=\frac{\sqrt2}{\sqrt \nu} \sqrt{x}$$ to make $$\sqrt{n} r=yq$$ and $$\text{d}y=\frac{\text{d}x}{\sqrt{2\nu x}}$$.
 * $$f(q;k,\nu)=\frac{\sqrt\nu}{\sqrt2^{\nu-1}\Gamma\left(\frac{\nu}{2}\right)}\int_0^\infty \sqrt{x}^{\nu-1} e^{-\frac{x}{2}}k(k-1)\sqrt n\int_{-\infty}^\infty \phi(t-\sqrt n r)\phi(t) \left[\Phi(t)-\Phi(t-\sqrt n r)\right]^{k-2}\text{d}t\frac{\text{d}x}{\sqrt{\nu 2 x}}$$
 * $$f(q;k,\nu)=\frac{\sqrt\nu^\nu}{2^{\nu-1}\Gamma\left(\frac{\nu}{2}\right)}\int_0^\infty y^{\nu-1} e^{-\frac{\nu y^2}{4}}k(k-1)\sqrt n\int_{-\infty}^\infty \phi(t-yq)\phi(t) \left[\Phi(t)-\Phi(t-yq)\right]^{k-2}\text{d}t\text{d}y$$