## 2 Using Legendre Polynomials for Randomized Projection Estimates
### Expansion Coefficients of Density and Distribution Function
In this case, the orthonormal Legendre polynomials \(\{\hat{P}_{i}^{*}\}_{i=0}^{\infty}\) are defined by the expression_  
\[\hat{P}_{i}^{*}(x)=\sqrt{\frac{2i+1}{b-a}}\,P_{i}\bigg{(}\frac{2x-(b+a)}{b-a} \bigg{)}.\]  
Algorithms for Jointly Obtaining Randomized Projection Estimates of Density and Distribution Functions  
The randomization of the projection estimate of the density \(g\) is obtained by the first equation of Formula (14) as a result of calculating linear functional (15) for the Legendre polynomials (6) by the Monte Carlo method with independent realizations of the random variable \(\xi\):  
\[\tilde{G}_{i}=\frac{1}{N}\sum_{l=1}^{N}\hat{P}_{i}(\xi_{l}),\ \ \ i=0,1,2,\ldots, \tag{21}\]  
where \(\xi_{l}\) is the \(l\)th realization and \(N\) is the sample size (number of realizations). Estimates \(\tilde{G}_{i}\) can also be obtained from expression (16) as  
\[\tilde{G}_{i}=\frac{1}{2^{i}}\sqrt{\frac{2i+1}{2}}\sum_{k=0}^{\lfloor i/2 \rfloor}\frac{(-1)^{k}(2i-2k)!}{k!(i-k)!(i-2k)!}\,\bar{\mathrm{M}}_{i-2k}, \tag{22}\]  
where \(\bar{\mathrm{M}}_{k}\) are statistical estimates of initial moments of the random variable \(\xi\),  
\[\bar{\mathrm{M}}_{k}=\frac{1}{N}\sum_{l=1}^{N}\xi_{l}^{k},\ \ \ k=1,2,\ldots, \tag{23}\]  
and \(\bar{\mathrm{M}}_{0}=1\). Using Formulae (4) and (5), we can write the expressions for the estimates of the density expansion coefficients separately for even indices (\(i=2j\)), as  
\[\tilde{G}_{2j}=\frac{1}{2^{2j}}\sqrt{\frac{4j+1}{2}}\sum_{k=0}^{j}\frac{(-1)^ {k}(4j-2k)!}{k!(2j-k)!(2j-2k)!}\,\bar{\mathrm{M}}_{2j-2k}, \tag{24}\]and for odd indices (\(i=2j+1\)), as  
\[\int_{-1}^{x}P_{0}(\theta)d\theta=\int_{-1}^{x}d\theta=x+1=P_{1}(x)+P_{0}(x),\]0  
The randomization of the projection estimate of the distribution function \(f\) is obtained by the second equation of Formula (14) and recurrence relations (20):  
\[\int_{-1}^{x}P_{0}(\theta)d\theta=\int_{-1}^{x}d\theta=x+1=P_{1}(x)+P_{0}(x),\]1  
Here and below, the dependence of the estimates of both expansion coefficients and functions on the sample size \(N\) is not indicated for simplicity. **Remark 3**. : _To obtain a projection estimate of the distribution function \(f\) based on the first \(n+1\) Legendre polynomials, it is necessary to find estimates of the expansion coefficients of the density \(g\) with respect to the first \(n+2\) Legendre polynomials._  
Further, we present Algorithm 1 for jointly obtaining randomized projection estimates of the density and distribution function of the random variable \(\xi\). ```
0. Set the projection expansion length \(n\) and the sample size \(N\). 1. Simulate \(N\) realizations \(\zeta_{l}\) of the random variable \(\xi\), \(l=1,2,\ldots,N\). 2. Find statistical estimates \(\bar{\mathrm{M}}_{k}\) of initial moments of the random variable \(\zeta\) using Formula (23), \(k=1,2,\ldots,n+1\). Set \(\bar{\mathrm{M}}_{0}=1\). 3. Find estimates of expansion coefficients \(\bar{G}_{i}\) of the density \(g\) using Formula (22) or Formulae (24) and (25), \(i=0,1,\ldots,n+1\). 4. Find estimates of expansion coefficients \(\bar{F}_{i}\) of the distribution function \(f\) using Formula (26), \(i=0,1,\ldots,n\). 5. Find randomized projection estimates \(\bar{g}^{\langle n\rangle}\) and \(\bar{f}^{\langle n\rangle}\) of the density and distribution function, respectively, using Formula (14). ```  
**Algorithm 1**Jointly obtaining projection estimates of the density and distribution function using explicit formulae for the Legendre polynomials. In step 3 in Algorithm 1, errors can occur due to the peculiarities of machine arithmetic when calculating expansion coefficients \(\bar{G}_{i}\). To avoid this, it is recommended to use Formula (21) together with recurrence relation (1) and expression (6). Next, we formulate Algorithm 2 for jointly obtaining randomized projection estimates of the density and distribution function. ```
0. Set the projection expansion length \(n\) and the sample size \(N\). 1. Simulate \(N\) realizations \(\zeta_{l}\) of the random variable \(\xi\), \(l=1,2,\ldots,N\). 2.