## 4 Proposed Approaches
### Threshold for Gap of Normalized Eigenvalues
#### 4.2.2 Learning and Computing Optimal Thresholds  
In the second step, two PDFs are derived from NN gaps dataset and NS gaps dataset. Then, the optimal threshold that minimizes source enumeration error probability is computed from the two PDFs. Let \(E_{\text{NN}}^{\text{data}}\) and \(E_{\text{NS}}^{\text{data}}\) follow PDF \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\), respectively, where \(x\) denotes the value of the gaps; \(x\) ranges from 0 to 1 because the eigenvalues are normalized. The objective of learning is to estimate \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\). By using the Gaussian mixture model (GMM) and the expectation-maximization (EM) algorithm, which are widely used in machine learning studies, \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\) are estimated. The two PDFs \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\) can be presented using GMM as follows:  
\[f_{\text{NN}}(x)=\frac{f(x;\phi_{\text{NN}})}{\int_{0}^{1}f(x;\phi_{\text{NN} })\,dx}, \tag{24}\]  
\[f_{\text{NS}}(x)=\frac{f(x;\phi_{\text{NS}})}{\int_{0}^{1}f(x;\phi_{\text{NS} })\,dx}, \tag{25}\]  
where  
\[f(x;\phi)=\sum_{i=1}^{K}\frac{w_{i}}{\sigma_{i}\sqrt{2\pi}}\text{exp}\bigg{(} -\frac{(x-\mu_{i})^{2}}{2\sigma_{i}^{2}}\bigg{)}, \tag{26}\]  
and \(\phi=\{(w_{i},\mu_{i},\sigma_{i}^{2})\}_{i=1}^{K}\) is a set of GMM parameters, \(K\) is the number of GMM components, \(w_{i}\) is the mixture weight of the \(i\)th component, \(\mu_{i}\) is the mean of the \(i\)th component,and \(\sigma_{i}^{2}\) is the variance of the \(i\)th component. Because \(x\) ranges from 0 to 1, \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\) should meet  
\[\int_{0}^{1}f_{\text{NN}}(x)\,dx=1, \tag{27}\]  
\[\int_{0}^{1}f_{\text{NS}}(x)\,dx=1, \tag{28}\]  
respectively; hence, \(f(x;\phi_{NN})\) and \(f(x;\phi_{\text{NS}})\) are divided by \(\int_{0}^{1}f(x;\phi_{NN})\,dx\) and \(\int_{0}^{1}f(x;\phi_{NS})\,dx\) as presented in (24) and (25), respectively. Algorithm 1 shows estimating \(\phi\) from a given dataset \(E^{\text{data}}\) using the EM algorithm. The details of EM algorithm are presented in [33]. Although \(K\) cannot be determined by the EM algorithm, by using Bayesian information criteria (BIC)--likelihood-based measures of model fit that include a penalty for complexity to avoid over-fitting [34]--\(K\) can be determined; the determined \(K\) is the value that minimizes BIC. In Algorithm 1, \(\phi_{k}\) is computed for every \(k\) from 2 to \(K^{\text{max}}\), where \(K^{\text{max}}\) is set properly before Algorithm 1 performed; if \(K^{\text{max}}\) too large, the computation time will incredibly increase, while \(K^{\text{max}}\) is too small, the optimal \(k\) may not be determined. For each \(k\), the BIC of \(f(x;\phi_{k})\) is calculated and saved to \(B_{k}\). After all BIC values are saved, Algorithm 1 selects \(k\) that minimizes BIC. Then, the \(\phi_{k}\) is returned where \(K\) is the selected \(k\). By Algorithm 1 and using \(E^{\text{data}}_{\text{NN}}\) and \(E^{\text{data}}_{\text{NS}}\), \(\phi_{NN}\) and \(\phi_{NS}\) can be obtained, respectively; finally, the two PDFs \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\) are obtained. ```
1:\(\text{{Re}}^{\text{data}}\)
2:for\(k=2\) to \(K^{\text{max}}\)do
3: Compute \(\phi_{k}=\{(w_{i},\mu_{i},\sigma_{i}^{2})\}_{i=1}^{k}\) with \(E^{\text{data}}\) using EM algorithm. 4: Calculate BIC for \(\phi_{k}\) and save the value to \(B_{k}\). \[B_{k}\leftarrow\text{BIC}(E^{\text{data}},f(x;\phi_{k}));\]
5:endfor
6:\(K\leftarrow\underset{k}{\text{argmin}}\;B_{k}\)
7:return\(\phi_{K}\)
```  
**Algorithm 1** Estimation of GMM parameters  
After \(f_{\text{NN}}(x)\) and \(f_{\text{NS}}(x)\) are estimated, the optimal threshold that minimizes source enumeration error probability is calculated.