# Passive Sonar Target Detection Using Statistical Classifier and Adaptive Threshold
## 3 Statistical Classifier and Adaptive Threshold
### Detection Point in Time Domain  
In this study, Bayesian algorithm is used to classify input signal. The target and noise signal have pseudo-Gaussian distribution, so applying the Bayesian algorithm has shown good results for extracting the target signal. To classify the target signal, the statistical distribution of the target signal and noise are estimated using training data. In this algorithm, if \(\theta\) represents label of target (\(s\)), noise (\(b\)), and \(x\) be a member of the input vector of the sound signal, the prior distribution \(\pi(\theta)\) the probability of noise and the target, Gaussian density function \(f(x|\theta)\) is the probability of the \(x\) value occurrence in the region of \(\theta\) and the posterior distribution \(p(\theta|x)\) is defined by (1):  
\[p(\theta|x)=\frac{\pi(\theta)f(x|\theta)}{\pi(s)f(x|s)+\pi(b)f(x|b)}\,,\quad \theta=s,b, \tag{1}\]  
The Gaussian density function \(f(x|\theta)\) is calculated by (2):  
\[f(x|\theta)=\sum\limits_{i=1}^{2}\omega_{\theta_{i}}N(\mu_{\theta_{i}},\sigma _{\theta_{i}}^{2}), \tag{2}\]  
where \(\omega_{\theta_{1}}=1-\omega_{\theta_{2}}\). The mixture parameters \(\omega_{\theta_{i}}\), \(\mu_{\theta_{j}}\), \(\sigma_{\theta_{j}}^{2}\), \(i=1,2\) can be initialized and updated using the MLE [18] algorithm. This algorithm is explained by (3):  
\[ \begin{array}{l}Z_{ij}^{(k)}=\frac{\omega_{\theta_{i}}^{(k)} \left(\epsilon_{\theta_{i}}^{(k)}\right)^{-1}\exp\left\{\left(2\omega_{\theta_ {i}}^{(k)}\right)^{-2}\left(x_{j}-\mu_{\theta_{i}}^{(k)}\right)\right\}}{\sum \limits_{i=1}^{\infty}\omega_{\theta_{i}}^{(k)}\left(\epsilon_{\theta_{i}}^{(k )}\right)^{-1}\exp\left\{\left(2\omega_{\theta_{i}}^{(k)}\right)^{-2}\left(x_{ j}-\mu_{\theta_{i}}^{(k)}\right)\right\}},\\ \omega_{\theta_{i}}^{(k+1)}=\frac{1}{N_{k}}\sum_{j=1}^{N_{k}}Z_{ij}^{(k)}\\ \mu_{\theta_{i}}^{(k+1)}=\frac{1}{N_{k}\omega_{\theta_{i}}^{(k+1)}}\sum_{j=1} ^{N_{k}}Z_{ij}^{(k)}x_{j}\\ \sigma_{\theta_{i}}^{(k+1)}=\frac{1}{N_{k}\omega_{\theta_{i}}^{(k+1)}}\sum_{j= 1}^{N_{k}}Z_{ij}^{(k)}\left(x_{j}-\mu_{\theta_{i}}^{(k)}\right)^{2}\end{array}  \tag{3}\]  
where, \(\omega_{\theta_{i}}^{(k)}\) is weights of normal distribution, \(\mu_{\theta_{i}}^{(k)}\) and \(\sigma_{\theta_{i}}^{(k)}\) is mean and variance of distribution in \(k^{th}\) iteration \((k\geq 0)\).Convergence condition is \(|\omega_{\theta_{i}}^{(k+1)}-\omega_{\theta_{i}}^{(k)}|<\varepsilon\). Finally, by estimate posterior distribution and based on (4) similar target signal (\(H_{0}\)) is separated from ambient noise (\(H_{1}\)). \[ \begin{cases}ifp(s|x)=\frac{1}{2}\Rightarrow AcceptH_{0}\\ ifp(s|x)\leq\frac{1}{2}\Rightarrow AcceptH_{1}\end{cases} , \tag{4}\]  
As mentioned, the classifier is performed in time and frequency domains. In the time domain, after classifier input signal (with lengths 10 thousand samples) into two classes of 0 (noise) and 1 (target), the resulting output has much continuity and discontinuity in some areas which due to the statistical similarity of target signal with noise. To solve the problem, the signal integrity characteristic of the target is used. In other words, the target signal has sectional continuity, which is also due to the continuous movement of the vessel propeller in the water. The marine diesel engines are turned on and off with bare-speed, and thus a sharp break does not occur in the propeller's sound. Thus, the result of classification is averaged by a windows with a width of \(w=1000\), which is selected experimentally and it is stored in a vector called mean vector \(\overset{\rightarrow}{a}\). In (5), how calculation this vector is shown. In this equation, \(n\) is number of sample and \(x\)(,) is the input signal. \[ \begin{array}{l}a_{i}=\frac{1}{w}\sum\limits_{k=(i-1)w+1}^{i\times w}x(k) \quad 1\leq i\leq\frac{n}{w}\,,\,0\leq a_{i}\leq 1\\ \overset{\rightarrow}{a}=\left[\begin{array}{ccc}a_{1}&a_{2}&\ldots&a_{n/w} \end{array}\right]\,,\end{array}  \tag{5}\]For calculation detection point, \(K\)-means (with \(K\) = 2) clustering algorithm is used.