## 4 Analysis and Conditional Optimization of Randomized Projection Estimates  
In this section, we analyze the error of the projection estimate \(\check{g}^{(n)}\) relative to the density \(g\) of the random variable \(\check{\varsigma}\) in \(L_{2}(\Omega)\). Let \(B(g,\check{g}^{(n)})=\mathrm{E}\|g-\check{g}^{(n)}\|_{L_{2}(\Omega)}\); then,  
\[B^{2}(g,\check{g}^{(n)})=\big{(}\mathrm{E}\|g-\check{g}^{(n)}\|_{L_{2}(\Omega) }\big{)}^{2}\leqslant\mathrm{E}\int_{\Omega}\big{(}g(x)-\check{g}^{(n)}(x) \big{)}^{2}dx\]  
due to [PERSON]'s inequality [21]. Further, we consider the following expression:  
\[\int_{\Omega}\big{(}g(x)-\check{g}^{(n)}(x)\big{)}^{2}dx=\|g-\check{g}^{(n)}\| _{L_{2}(\Omega)}^{2}=\|g-g^{(n)}+g^{(n)}-\check{g}^{(n)}\|_{L_{2}(\Omega)}^{2}.\]  
Functions \(g-g^{(n)}\) and \(\check{g}^{(n)}-\check{g}^{(n)}\) are orthogonal in \(L_{2}(\Omega)\) since they belong to different subspaces. The first one is formed by the Legendre polynomials \(\hat{P}_{i}\) for \(i=n+1,n+2,\dots,\) and the second one is formed by the Legendre polynomials \(\hat{P}_{i}\) for \(i=0,1,\dots,n\). This is a consequence of the equalities  
\[g(x)=\sum_{i=0}^{\infty}G_{i}\hat{P}_{i}(x),\ \ \ g^{(n)}(x)=\sum_{i=0}^{n}G_{i} \hat{P}_{i}(x),\ \ \ \check{g}^{(n)}(x)=\sum_{i=0}^{n}G_{i}\hat{P}_{i}(x);\]  
hence,  
\[\|g-g^{(n)}+g^{(n)}-\check{g}^{(n)}\|_{L_{2}(\Omega)}^{2}=\|g-g^{(n)}\|_{L_{2 }(\Omega)}^{2}+\|g^{(n)}-\check{g}^{(n)}\|_{L_{2}(\Omega)}^{2}.\]  
According to [PERSON]'s identity [9], we have  
\[\|g^{(n)}-\check{g}^{(n)}\|_{L_{2}(\Omega)}^{2}=\left\|\sum_{i=0}^{n}(G_{i}- \bar{G}_{i})\hat{P}_{i}(x)\right\|_{L_{2}(\Omega)}^{2}=\sum_{i=0}^{n}(G_{i}- \bar{G}_{i})^{2}\]  
and  
\[\int_{\Omega}\big{(}g(x)-\check{g}^{(n)}(x)\big{)}^{2}dx=\sum_{i=0}^{n}(G_{i} -\bar{G}_{i})^{2}+\|g-g^{(n)}\|_{L_{2}(\Omega)}^{2}.\]  
Therefore, taking into account that the unbiased estimate of mathematical expectation is used [18], namely, \(\mathrm{E}\bar{G}_{i}=G_{i}\), we obtain  
\[B^{2}(g,\check{g}^{(n)}) \leqslant\mathrm{E}\left(\sum_{i=0}^{n}(G_{i}-\bar{G}_{i})^{2}+\| g-g^{(n)}\|_{L_{2}(\Omega)}^{2}\right) \tag{27}\] \[=\sum_{i=0}^{n}\mathrm{E}(G_{i}-\bar{G}_{i})^{2}+\|g-g^{(n)}\|_{L _{2}(\Omega)}^{2}\] \[=\sum_{i=0}^{n}\mathrm{D}\bar{G}_{i}+\|g-g^{(n)}\|_{L_{2}(\Omega) }^{2},\]  
where \(\mathrm{D}\) denotes the variance. The equality \(\bar{G}_{0}=G_{0}\) is satisfied since \(\hat{P}_{0}(x)=\mathrm{const}\), i.e., \(\mathrm{D}\bar{G}_{0}=0\). For \(i>0\), the variance of estimates \(\bar{G}_{i}\) and the sample size \(N\) are inversely proportional [22]; therefore, using additionally inequality (9) under the condition \(g\in W_{2}^{s}(\Omega)\) (see Remark 1), we find  
\[B^{2}(g,\check{g}^{(n)})\leqslant\frac{C_{1}^{g}n}{N}+\frac{C_{2}^{g}}{n^{2g}}, \tag{28}\]  
where \(C_{1}^{g},C_{2}^{g}>0\) are constants independent of \(n\) and \(N\). The error of the projection estimate \(\bar{f}^{(n)}\) relative to the distribution function \(f\) of the random variable \(\xi\) in \(L_{2}(\Omega)\) is analyzed similarly:  
\[\int_{\Omega}\big{(}g(x)-\check{g}^{(n)}(x)\big{)}^{2}dx=\|g-\check{g}^{(n)}\| _{L_{2}(\Omega)}^{2}=\|g-g^{(n)}+g^{(n)}-\check{g}^{(n)}\|_{L_{2}(\Omega)}^{2}.\]0  
where \(C_{1}^{f},C_{2}^{f}>0\) are constants independent of \(n\) and \(N\). From the obtained estimates, it is clear how the mean square error depends on the projection expansion length \(n\) and the sample size \(N\). Further, we consider a problem of the optimal (consistent) choice of parameters for statistical algorithms to obtain projection estimates of the density and distribution function: the projection expansion length \(n\) and the sample size \(N\). For jointly obtaining these estimates by Algorithms 1 and 2, it is sufficient to consider the optimal choice of parameters for density estimation only and use them for distribution function estimation. This is because the degree of smoothness of \(f\) is greater than the degree of smoothness of \(g\), so the sequence \(\bar{f}^{(n)}\) converges to \(f\) faster than the sequence \(\bar{g}^{(n)}\) converges to \(g\).