# Joint Normal vs Chi-Square PDF in Distance Testing

In my previous question (Integrating Joint Normal Distribution in R3), I describe a joint normal PDF with three independent random variables of $\mathbf N_3(0,\mathbf I)$. The joint pdf is $p(x,y,z)=p(x)p(y)p(z)={(1/\sqrt {2\pi})}^3e^{-{(x^2+y^2+z^2})/2}$ and the distribution I'm interested in becomes $$P(r<r_o)={(1/\sqrt {2\pi})}^3\int _{x^2+y^2+z^2<r_o^2}e^{-{(x^2+y^2+z^2})/2} dxdydz$$ This can be integrated through change of variables and use of integration by parts to

(Updated/Corrected)
\begin{align} \ P(r<r_o) & = {(1/\sqrt {2\pi})}^3 \int _{0 \le r \le r_o} 4\pi r^2 e^{-r^2/2} dr \\ & = erf(\frac{r_o}{\sqrt{2}}) - \sqrt{ \frac{2}{\pi}} r_o e^{- \frac{r_o^{2}}{2}} \end{align}

On the other hand, I would expect $P(r<r_o) \equiv P(r^2<r_o^2)$

This is where colleagues expect a degree-3 $\chi^2$ distribution to be applicable. For this I used the formula from Wikipedia for the cumulative distribution of the $\chi^2$ with k=3 for three degrees of freedom:

$$F(x;k)=\frac{\gamma(\frac{k}{2},\frac{x}{2})}{\Gamma(\frac{x}{2})}$$

Using $x=r^2$, I used this Matlab code to model it:

chi2Dist = gammainc(r.^2/2, 3/2,'lower') / gamma(3/2);


A plot comparing the two CDFs is shown below, and apart from the obvious scaling error in the $\chi^2$ CDF, they look like a match. I'd like some ideas on how to show they are the same (or not). (Also, how did I get the scale wrong on the $\chi^2$ CDF?)

• There must be "-" instead of "+" in the second line of $P(r<r_0)$. Also $1/\sqrt{2}$ should not be there, i.e. $$P(r\le r_0)=erf\left(\frac{r_o}{\sqrt{2}}\right) -\sqrt{ \frac{2}{\pi}} r_o e^{- \frac{r_o^{2}}{2}}$$ – d.k.o. Mar 7 '16 at 5:53
• Thanks, I see that now. I'll make the correction. – Jim Mar 7 '16 at 19:48

The reason why you have a scaling problem is because the Matlab function gammainc() is already regularized. Refer to the documentation for this function. You will see that the integral is already divided by $\Gamma(a)$. The function $\gamma(a,z)$ as described in the Wikipedia article is the non-regularized (lower) incomplete gamma function--it isn't divided out.

As for a proof that the two are the same, it should be obvious without any need for integration for the reasons you already alluded to. However, if you want to actually perform the integration of the chi-squared density, just explicitly compute the CDF from the density, then apply a transformation.