System Identification with Periodic Signal Input I want to find the ETFE (Empirical Transfer Function Estimate) of the system $G(e^{j\omega})$:



Where $H(e^{j\omega})$ is some filter that zero-mean white Gaussian noise $e(k)$ passes through. Let's assume that the input $u(k)$ is periodic with period $M$. Taking the Discrete Fourier transform, I have:

$$
Y_N(e^{j\omega_n})=\sum_{k=0}^{N-1}{y(k)e^{-j\omega_nk}}\quad\text{where }\omega_n=\frac{2\pi n}{N}\quad n=0,1,\ldots,N-1
\tag{1}$$

$$
U_N(e^{j\omega_n})=\sum_{k=0}^{N-1}{u(k)e^{-j\omega_nk}}\quad\text{where }\omega_n=\frac{2\pi n}{N}\quad n=0,1,\ldots,N-1 
\tag{2}$$

$$
V_N(e^{j\omega_n})=\sum_{k=0}^{N-1}{v(k)e^{-j\omega_nk}}\quad\text{where }\omega_n=\frac{2\pi n}{N}\quad n=0,1,\ldots,N-1 
\tag{3}$$

Therefore, I have:

$$
Y_N(e^{j\omega_n})=G(e^{kj\omega_n})U_N(e^{j\omega_n})+V_N(e^{j\omega_n})+R_N(e^{j\omega_n}) 
\tag{4}$$

Where $N=r\cdot M$ where $r\in \mathbb Z$ is an integer number of periods. I also added $R_N(e^{j\omega_n})$ as the transient part of the response (it would die out for example after the first period of the response). The ETFE is then:

$$
\hat G_N(e^{kj\omega_n})=\frac{Y_N(e^{j\omega_n})}{U_N(e^{j\omega_n})}=G(e^{kj\omega_n})+\frac{R_N(e^{j\omega_n})}{U_N(e^{j\omega_n})}+\frac{V_N(e^{j\omega_n})}{U_N(e^{j\omega_n})}
\tag{5}$$

Let's define the error between the ETFE and the true transfer function as:

$$
E_N(e^{j\omega_n})=G(e^{kj\omega_n})-\hat G_N(e^{kj\omega_n})
\tag{6}$$

In my System Identification course, the professor presented two case scenarios. One where input $u(k)$ is zero-mean Gaussian non-periodic noise of length $N$, and one where $u(k)$ is some zero-mean Gaussian noise sequence of length $M$ repeated $r$ times - which makes a periodic signal of sorts. Here is the plot of the norm of $E_N(e^{j\omega_n})$ in the non-periodic case:



And here is the plot of the norm of $E_N(e^{j\omega_n})$ in the periodic case:



In the second picture, the period $M=128$ so for example for $N=128$ we have $r=1$ (only one period was considered) and for $N=512$ we have $r=4$ (four periods were considered).

Also in both of the above figures, the professor took the expectation of the error $E_N$, i.e. he actually ran the experiment 1000 times and took the average $E_N$ for each frequency, which is what helps to give the "smooth" error curve.

My question: I do not understand what makes the error $E_N$ stay the same as we increase $N$ for the non-periodic input case, but makes $E_N$ decrease in the periodic case as we increase the number of periods that we collect.

Thank you for your help!
The point is, that you need to look at the influence of averaging on the final term in the equation

$$ \hat{G}_N = [...] + \frac{V_N}{U_N}. $$

In case of periodic excitation $u$, the noise term $|V_N|$ is decreased by averaging over independent realizations (=measurements). However $|U_N|$ is not affected by averaging, as each period of u(t) is identical.

In case of non-periodic excitation, both terms are affected in the same way. As each is different, $|U_N|$ is reduced by averaging and so does the quotient $|\frac{V_N}{U_N}|$ and  $|E_N|$.

Note: In your example plots you do not take averages in the non-periodic case. The frequency resolution in the first plot is different for each N. If the non-periodic signal is split in segments with equal length and averaged over segments, the frequency resolution would be the same for all N. However in your plot  you just compute longer DFTs that result in finer frequency resolution. However this is not relevant for the answer.

Edit: Extended my notes on DFT lenghts; thanks to Maximilian Matthé for his comment.