Solution (source code)

= Solution

For a centered <weakly stationary process> with $\gamma(0)>0$, the <autocorrelation function> is
$$
\boxed{\rho(h)=\gamma(h)/\gamma(0).}
$$
For $h\geq2$, let $P$ be <orthogonal projection> in <L2 space> onto the linear span of $X_{t-1},\ldots,X_{t-h+1}$. The lag-$h$ <partial autocorrelation function> is the <correlation coefficient> of $X_t-PX_t$ and $X_{t-h}-PX_{t-h}$. It removes the linear contribution of the intervening observations. At lag one it is just $\rho(1)$. For nonsingular prediction <covariance> matrices, it is equivalently the last coefficient $a_{hh}$ in the order-$h$ linear predictor of $X_t$ from $X_{t-1},\ldots,X_{t-h}$. Equal residual variances, by stationarity, identify that coefficient with the residual correlation. If a residual has zero <variance>, this correlation is undefined; the nondegeneracy condition matters.