# In-Field Quantum-Protected Control-Based Key Distribution with a Lossy Urban Fiber Link
## 7 Methods
### Statistical Analysis  
On par with the NIST statistical test, the results of which are presented in Table 1, we perform additional analysis of the central moments of the key distribution, that may provide better understanding of the key's quality. Ideally, the secret bit sequence must follow the equiprobable Bernoulli distribution. To check this, we divide this array of bits into consecutive blocks of length \(n\), and for each of these \(k(n)\) blocks, we calculate the sum of its bit values, producing a random variable \(X_{n}\). This division would result in a random sample \(\{X_{n}^{i}\}_{i=1}^{k(n)}\) of size \(k(n)\), in which \(X_{n}^{i}\) are taken from a population following binomial distribution \(Bi(n,p)\) with \(p=0.5\). Therefore, analyzing the central moments \(\mathbb{E}\left[(X_{n}-\mathbb{E}[X_{n}])^{2}\right]\) would allow us to know how far the initial distribution is from the ideal theoretical model. More precisely, if the central moment of the sample \(\{X_{n}^{i}\}_{i=1}^{k(n)}\) is too far from its theoretical prediction, the fidelity of the model would be questioned for this particular \(n\). This approach allows us to identify the frequency of the noise, should it worsen the quality of the key. In this way, by increasing the length of the blocks \(n\), we shift our focus from higher to lower frequency noise, as small blocks fail to capture low frequency effects. For this reason, we test the final key on a wide range of \(n\), tracing the deviation from the theoretical model. The results for the first two central moments are presented in Figure 6a,b. The error bars in these plots reflect the finiteness of the sample size \(k(n)\), and in our case can be easily found only for the first two moments. We first note that the binomial distribution \(Bi(n,p)\) tends to the Gaussian distribution in the limit \(n\to\infty\). Therefore, our objective reduces to determining the variance \(s^{2}\) in the random sample \(\{X_{n}^{i}\}_{i=1}^{k(n)}\), where each \(X_{n}^{i}\) is drawn from a Gaussian population with variance \(\sigma_{0}^{2}\). For such an unbiased sample variance, it is known that \(\frac{(k(n)-1)s^{2}}{\sigma_{0}^{2}}\) has a chi-squared distribution with \(k(n)-1\) degrees of freedom. In our case, \(\sigma_{0}^{2}=np(1-p)\). Therefore, we can determine that  
\[\mathbb{V}\left[\mathbb{E}\left[(X_{n}-\mathbb{E}[X_{n}])^{2}\right]\right] \approx\frac{2n^{2}p^{2}(1-p)^{2}}{k(n)}, \tag{7}\]  
where \(\mathbb{V}[\cdot]\) is the variance in the sample data. This result allows us to plot \(2\sigma\) confidence intervals in Figure 6b. A similar result can be obtained for the sampling distribution of the sample mean. This result is called the central limit theorem, which in our case leads to the following result:  
\[\mathbb{V}\left[\mathbb{E}[X_{n}]\right]=\frac{np}{\sqrt{n}}=\sqrt{n}p. \tag{8}\]  
This analysis is shown in Figure 6a. Finally, in Figure 6c, we show the dynamics of the parameter \(p\), fitting the experimental data to the theoretical model described above for a fixed value of \(n\). A small deviation of the estimated value of \(p\) from the target value \(0.5\) and small values of its autocorrelation confirm the high quality of the final key. According to these results, the final key is well described by the model. In particular, the bits in the final key can be represented as random variables following a Bernoulli distribution with a parameter \(p=0.5\), within the limits of statistical precision. Consequently, we can conclude that any noise affecting the key statistics has been effectively mitigated by the postprocessing methods used. **Author Contributions:** [PERSON] and [PERSON] conceptualized the work; [PERSON]. ([PERSON]) and [PERSON] designed the experiment; [PERSON]. ([PERSON]), [PERSON] ([PERSON]), [PERSON] and [PERSON] assembled the experimental setup. [PERSON]. ([PERSON]) and [PERSON] collected and processed data related to the distributed key. [PERSON] conducted a statistical analysis and quality assessment of the key. [PERSON].