## 3 Efficient Learning Algorithm
### Fast Calculations and Smoothing  
The crucial, mostly time-consuming step is smoothing preprocessed data contained in matrix \(P\). Therefore, it is expedient to apply 2D FFT in order to calculate the DFT of \(P\):  
\[G\,=\,FFT_{\text{2D}}(P;\,M,\,N), \tag{12}\]  
where the resulting \(M\times N\) matrix \(G\) has complex elements \(g_{mn}\), \(n=1,\,2,\,\dots,\,N\), \(m=1,\,2,\,\dots,\,M\) (see, e.g., [19] for the definition of 2D DFT and its implementation as 2D FFT). Obviously, the inverse transform provides \(P=FFT_{\text{2D}}^{-1}(G;\,M,\,N)\). Thus, in order to smooth \(P\), we have to remove high frequency components from matrix \(G\), retaining only its, appropriately chosen, \(K\times J\) sub-matrix \(\hat{G}\), \(1<K<M,\,1<J<N\) and setting to zero other elements of \(G\) Instead of setting zeros, one can apply at this stage so-called windowing, e.g., using the Hamming window that provides a mild way of approaching zero. **Remark 1**. : _The appropriate choice of \(K\times J\) sub-matrix \(\hat{G}\), with elements \(\hat{g}_{kj}\), means that we have to take into account that the complex valued matrix \(G\) has the component corresponding to \((0,\,0)\) frequency, which is placed as \(g_{11}\) (or \(g_{MN}\)). Analogously, other components of \(G\), corresponding to low frequencies, are placed at the \"corners\" of this matrix. Hence, in order to cancel high frequencies, we have to reshape matrix \(G\) in order to have \((0,\,0)\) frequency in its middle and other low frequencies nearby. Then, to put zeros at the positions corresponding to high frequencies, select sub-matrix \(\hat{G}\) and reshape it in the order reverse to that of the reshaping \(G\). This last step is necessary so as to obtain a smoothed version of the \(P\) matrix, which would be a \(K\times J\) matrix._  
**Remark 2**. : _It is crucial for further considerations to observe that \(\hat{\alpha}_{kj}\)'s are directly calculable from \(\hat{g}_{jk}\)'s and their conjugates by adding or subtracting their real and imaginary parts._  
**Remark 3**. : _The choice of \(K\), \(J\) or the choice of indexes \(k\), \(j\) for which \(\text{al}\hat{p}\hat{n}\hat{k}_{kj}\) is left as nonzero, is crucial for proper functioning of the estimation algorithm, since their choice dictates the amount of smoothness of the resulting surface. Below, we discuss possible ways of learning the algorithm to select them properly._  
_Although the \(\mathcal{F}\) estimation problem differs from the one of estimating bi-variate p.d.f. 's, we may consider the methods elaborated in this field as candidates that might be useful also here._  
1. _The cross-validation approach--see_ _[_20_]__, where the asymptotic optimality of this method is proved for the trigonometric and the Hermite series density estimators,_2. _The Kronmal and Tarter rule_ _[_21_]__, which--in our case--reads as follows. For_ \(m=1\)_,_ \(2\)_,_ \(\ldots M\) _and_ \(l=1\)_,_ \(2\)_,_ \(\ldots N\)_, check the following condition:_ \[|g_{kl}|^{2}>c\big{/}M\,N,\] (13) _where_ \(c>0\) _is a preselected constant. According to derivations in_ _[_21_]__,_ \(c=1\) _, but in the same paper it is advocated to use_ \(c=0.5\)_. From our simulation experiments, it follows that for moderate_ \(M\) _and_ \(N\)__\(c=1.5\) _is appropriate, while, for larger_ \(M\)_,_ \(N\)_, even larger constants are better. If for_ \(g_{kl}\) _condition (_13_) holds, then leave it in matrix_ \(G\) _as a nonzero element. Otherwise, set_ \(g_{kl}=0\) _in this matrix. Set_ \(\hat{G}=G\)_. Notice that in this case matrix_ \(\hat{G}\) _is of the same dimensions as_ \(G\)_, but it has many zeros as its elements._  
Selection of \(\Delta_{r}\) and \(\Delta_{x}\) (or equivalently \(M\) and \(N\)) as functions of the number of observations is also very important for the proper estimation. We give some hints on their choice in the section before last, where the asymptotic analysis is discussed. The performance of Algorithm 1 is illustrated in the next section.