[step:Identify the distribution of one Gram-Schmidt step]Fix $j \in \{1,\dots,p\}$. Let $\mathcal{F}_{j-1}$ denote the $\sigma$-algebra generated by $X_1,\dots,X_{j-1}$; for $j=1$, let $\mathcal{F}_0 := \{\varnothing,\Omega\}$. On the full-probability event where $q_1,\dots,q_{j-1}$ are defined, extend this orthonormal family to an orthonormal basis
\begin{align*}
q_1,\dots,q_{j-1},e_j,\dots,e_n
\end{align*}
of $\mathbb{R}^n$, where each $e_k$ is chosen as an $\mathcal{F}_{j-1}$-measurable vector. To construct the completion measurably, process the fixed deterministic basis $u_1,\dots,u_n$ of $\mathbb{R}^n$ in order, project each $u_m$ onto the orthogonal complement of the span of the vectors already selected, and keep the first vector whose projected norm is nonzero. The ordering gives a fixed tie-breaking rule on the full-probability rank event; on its complement, define the remaining $e_k$ arbitrarily, for instance by the same deterministic basis. Each projection and norm is a Borel function of $q_1,\dots,q_{j-1}$, so the selected vectors are $\mathcal{F}_{j-1}$-measurable.
Define the $\mathcal{F}_{j-1}$-measurable orthogonal matrix
\begin{align*}
O_j:\Omega \to \mathbb{R}^{n \times n}
\end{align*}
whose rows are $q_1,\dots,q_{j-1},e_j,\dots,e_n$ in that order. Since $X_j$ is independent of $\mathcal{F}_{j-1}$ and has distribution $\mathcal{N}_n(0,I_n)$, conditioning on $\mathcal{F}_{j-1}$ fixes the matrix $O_j$. For every deterministic orthogonal matrix $O \in \mathbb{R}^{n \times n}$, the transformed vector $OX_j$ again has law $\mathcal{N}_n(0,I_n)$ by rotational invariance of the standard Gaussian law. Therefore, conditional on $\mathcal{F}_{j-1}$, the coordinates of $X_j$ in this orthonormal basis are independent standard normal random variables. Define these coordinate random variables by
\begin{align*}
Z_i &:= q_i \cdot X_j, && 1 \leq i < j, \\
Z_k &:= e_k \cdot X_j, && j \leq k \leq n.
\end{align*}
Then, conditional on $\mathcal{F}_{j-1}$, the family
\begin{align*}
Z_1,\dots,Z_{j-1},Z_j,\dots,Z_n
\end{align*}
consists of independent $\mathcal{N}(0,1)$ random variables.
By construction, for $1 \leq i<j$,
\begin{align*}
r_{ij}=q_i \cdot X_j=Z_i.
\end{align*}
The residual vector is the [orthogonal projection](/theorems/437) of $X_j$ onto the orthogonal complement of $\operatorname{span}\{q_1,\dots,q_{j-1}\}$:
\begin{align*}
Y_j = \sum_{k=j}^n Z_k e_k.
\end{align*}
Hence
\begin{align*}
r_{jj}^2 = |Y_j|^2 = \sum_{k=j}^n Z_k^2.
\end{align*}
Therefore, conditional on $\mathcal{F}_{j-1}$,
\begin{align*}
r_{1j},\dots,r_{j-1,j}
\end{align*}
are independent $\mathcal{N}(0,1)$ random variables, $r_{jj}^2$ has distribution $\chi^2_{n-j+1}$, and $r_{jj}$ is independent of $r_{1j},\dots,r_{j-1,j}$.[/step]