Quadratic form of a standard normal vector (source code)

= Quadratic form of a standard normal vector

If $Z\sim N_p(0,I_p)$, then $Z^TZ=\sum_{j=1}^pZ_j^2\sim\chi_p^2$.