# SCATTER PHY: An Open Source Physical Layer for the DARPA Spectrum Collaboration Challenge
## Appendix A Two-Stage Detection Algorithm
### Step # 1: Censoring and Calculation of the Noise-Power Reference Level  
In this first step, PDP samples containing the presence of other than noise observations, i.e., corrupted PDP samples, are removed (i.e., censored) from the PDP reference set. Corrupted samples are caused by the presence of samples containing noise plus another signal (i.e., a signal different from noise). For the discarding/removal of corrupted PDP samples, we employed the algorithm known as Forward Consecutive Mean Excision (FCME) [30]. To begin with, the samples in the PDP set can be defined as:  
\[\left\{\mathrm{PDP}(m)\mid m=0,1,\cdots,N_{\mathrm{Synch}}-1\right\}, \tag{10}\]  
and then, the PDP samples are sorted in ascending order of values; this way, the sorted PDP set can be defined as:  
\[\left\{\mathrm{PDP}^{(i)}\mid i=0,1,\cdots,N_{\mathrm{Synch}}-1\right\}, \tag{11}\]  
where:  
\[\mathrm{PDP}^{(0)}\leq\mathrm{PDP}^{(1)}\leq\mathrm{PDP}^{(2)}\leq\cdots\leq \mathrm{PDP}^{(N_{\mathrm{Synch}}-1)}. \tag{12}\]The discarding of corrupted PDP samples, at the \(k^{\text{th}}\) iteration of the algorithm, is carried out through the application of the following inequality:  
\[\text{PDP}^{(k+1)}\geq T_{k}\sum_{i=1}^{k}\text{PDP}^{(i)}, \tag{10}\]  
where \(T_{k}\) corresponds to the discarding/censoring scaling factor at the \(k^{\text{th}}\) iteration of the censoring algorithm. If the inequality shown in (10) holds, all the PDP samples that present values greater than \(\text{PDP}^{(k+1)}\) are considered to be corrupted. The testing of (10) is carried out iteratively, where it is necessary to compute the censoring scaling factor, \(T_{k}\), for every new iteration of the algorithm. The discarding scaling factor, \(T_{k}\), rules the properties of the discarding step of the detection algorithm. This parameter is generally chosen in order that the probability of false disposal, \(P_{FD}\), presents a pre-defined value. The probability of making an incorrect decision during the \(k^{\text{th}}\) iteration of the discarding step is denoted by \(P_{FD}\). The initial value of \(T_{k}\) is computed considering that \(\text{PDP}^{(k+1)}\) is a PDP sample that does not contain the presence of the synchronization sequence, i.e., a PDP sample containing a noise-only observation. Based on this premise, the probability that the inequality given by (10) holds corresponds to the probability of false disposal, \(P_{FD}\), defined as:  
\[P_{FD}=P\left\{\text{PDP}^{(k+1)}\geq T_{k}\sum_{i=1}^{k}\text{PDP}^{(i)}\mid H _{0}\right\}. \tag{11}\]  
Every iteration of the discarding step initializes with the parameter \(k\) being equal to the smallest supposed clean set (i.e., noise-only set) of PDP samples. The larger the supposed clean set, the better the discarding algorithm works [30]. However, the larger the supposed clean set is, the higher is the likelihood that corrupted PDP samples (i.e., samples containing other than noisy-only observations) will be part of the initial supposed clean set. The testing of (10) proceeds until it is true for some value of the parameter \(k\) or all PDP samples used as a reference are considered to be noise-only (i.e., signal-free) samples.