# Detection of Unknown Signals

This example shows how to design a detector to detect an unknown signal embedded in ambient noise. Due to the generally unknown signal, the matched filter cannot be used for detection. In this case, the baseline detector is an energy detector. As the energy detector does not use any prior information, the energy detector can hardly detect the signal given a low false alarm rate. The goal of this example is to show how to improve the detection performance by using additional knowledge of the signal.

### What Is an Unknown Signal Detection Problem?

Our obtained data $x$ is the noise-free signal $s$ embedded in complex white Gaussian noise $n$ with noise power ${\sigma}^{2}$:

$x=s+n.$

For simplicity, we assume the noise power ${\sigma}^{2}$ is known from additional noise data. The goal of the unknown signal detection problem is to solve the following hypothesis testing problem:

$$\{\begin{array}{cc}{\mathcal{H}}_{0},\phantom{\rule{0.5em}{0ex}}& x=n,\\ {\mathcal{H}}_{1},\phantom{\rule{0.5em}{0ex}}& x=s+n,\end{array}$$

where $${\mathcal{H}}_{0}$$ is referred to as the null hypothesis and $${\mathcal{H}}_{1}$$ as the alternative hypothesis. This problem can be solved by comparing the ratio of likelihood functions under each hypothesis to a threshold. The result can be simplified to comparing detection statistics $$T(x)$$ to a detection threshold $$\gamma $$. The detector decides $${\mathcal{H}}_{1}$$ is true (a signal is detected) if $$T(x)>\gamma $$, and decides $${\mathcal{H}}_{0}$$ is true (no signal is detected) otherwise.

The performance of the detector heavily relies on the detection statistics $$T(x)$$, while the detection statistics $$T(x)$$ depends on the model and knowledge of the signal. If the model of the signal is incorrect, the detection performance will be poor. If the model of the signal is close to the true signal, the detection performance heavily depends on the knowledge of the parameters in the signal model. Thus, in the following, we first introduce how to choose a signal model. Then, we mainly focus on how to design detectors according to the knowledge in the signal model.

### How to Select a Signal Model?

In general, there are 3 steps to select a signal model. We illustrate the 3 steps using the following example.

Let's consider that the true unknown signal $s$ is a periodic signal composed of the fundamental and first 4 harmonics.

#### Step 1: Choose A General Signal Model Type.

The periodic signal can be represented as a Fourier series. The Fourier series model of $s$ is given as

$s[n]={\sum}_{k=1}^{P}{\alpha}_{k}{e}^{-j2\pi kn{f}_{0}/{f}_{s}},n=0,1,2,...,N-1,$

where ${f}_{0}$ is the fundamental frequency of the periodic signal, ${f}_{s}$ is the time-domain sampling frequency, $N$ is the number of time-domain samples, ${\alpha}_{k}$ is the complex amplitude of the $k$-th signal component, and $P$ is the number of signal components (1 fundamental and the first $P-1$ harmonics).

#### Step 2: Choose The Model Order.

In this example, the model order is the number of signal components $P$.

#### Step 3: Choose The Values of Parameters.

The values of parameters can be either known or unknown. In this example, the sampling frequency ${f}_{s}$ and the number of time-domain samples $N$ are known. The fundamental frequency ${f}_{0}$, the complex amplitudes of the signal components ${\alpha}_{k},k=1,2,...,K$ are in general unknown.

### Design Detectors According to Knowledge in Signal Model

We configure the periodic signal in the `UnknownSignalDetectionSimulink_params`

function and configure $P=5$, ${f}_{0}=1{0}^{6}\text{}\text{MHz}$, $N=256$, ${\sigma}^{2}=50\text{}\text{watt}$, and the signal to noise ratio (SNR) $$\frac{{s}^{H}s}{{\sigma}^{2}}$$ approximately to be 10 dB. The amplitudes of the signal components are selected to model signal attenuation in a channel where higher frequency components experience stronger attenuation.

In the following, we detect the existence of the periodic signal $s$ from the data $x$ using three detectors: energy detector, LRT detector, and GLRT detector. These detectors assume different knowledge of the signal model. An overview of the Simulink models is given below.

load_system('UnknownSignalDetectionSimulink'); open_system('UnknownSignalDetectionSimulink');

#### Baseline Detector: Energy Detector

For the energy detector, the true signal $s$ is assumed to be fully unknown. The detection statistics of the energy detector is

${T}_{ED}(x)=\frac{{x}^{H}x}{{\sigma}^{2}/2}\text{,}$

where $${x}^{H}x$$ is the signal power summed over time. Under hypothesis $${\mathcal{H}}_{0}$$ (when the signal is not present), the detection statistics $${T}_{ED}(x)$$ follows the chi-squared distribution with $2N$ degrees of freedom, i.e., ${T}_{ED}(x)\sim {\chi}_{2N}^{2}$. Thus, for a given probability of false alarm ${P}_{FA}$, the detection threshold of the energy detector is given by

${\gamma}_{ED}={Q}_{{\chi}_{2N}^{2}}^{-1}(1-{P}_{FA})\text{,}$

where $${Q}_{{\chi}_{2N}^{2}}^{-1}(1-{P}_{FA})$$ is the inverse cumulative distribution function (CDF) of the chi-squared distribution with degrees of freedom $2N$, evaluated at the probability values in $$1-{P}_{FA}$$.

In this example, the energy detector is implemented in the `Energy Detector`

block. The inputs of the energy detector are the data $x$ and the known noise power ${\sigma}^{2}$. We configure the probability of false alarm ${P}_{FA}=0.01$. Run the simulation for 1 second to generate multiple independent data samples over time and use scope to display the detection result for each data sample. We can observe that the energy detector can only output very few detected results in the 1 second duration. The detection rate of the energy detector is also very low.

#### Ideal Detector: LRT Detector

To show the potential detection performance improvement, we use the LRT detector to show the performance upper bound for the detection problem.

The LRT detector assumes the perfect knowledge of the signal $s$ and applies the matched filter to detect the signal. The detection statistics of the LRT detector for complex data is

${T}_{LRT}(x)=real\left(\frac{{s}^{H}x}{\sigma \sqrt{{s}^{H}s}}\right)\text{.}$

For a given probability of false alarm ${P}_{FA}$, the detection threshold of the LRT detector for complex data is given by

${\gamma}_{LRT}={Q}^{-1}(2{P}_{FA})\text{,}$

where $${Q}^{-1}(2{P}_{FA})$$ is the inverse complementary error function evaluated at the value $2{P}_{FA}$. For more information about the LRT detector, please refer to the documentation page of `phased.LRTDetector`

.

In this example, the LRT Detector block is used for LRT detection. The inputs of the LRT detector are the data $x$, the known signal $s$ and the known noise power ${\sigma}^{2}$. Run the simulation under the same configuration as the energy detector and use the scope to display the result. The LRT detection result and detection rate show that there is a great potential for detection performance improvement compared to the energy detector. However, it is hard to attain this performance upper bound in practice because we don't fully know the periodic signal $s$.

#### Practical Detector: GLRT Detector

A more practical detector that can improve the detection performance is the GLRT detector. We design a GLRT detector as follows.

#### Signal Model Selection

We design the GLRT detector by first selecting a more detailed signal model following the 3 steps introduced in the last section.

We select the Fourier series model of $s$ described in the last section.

We choose the model order $$P=3$$. That is, we assume the signal contains 1 fundamental and first 2 harmonics, which predicts less harmonics than the true signal but captures the most significant ones, because only the first few harmonics typically have significant amplitudes.

We choose the complex amplitudes of the 3 signal components $$\theta =[{\alpha}_{1},{\alpha}_{2},{\alpha}_{3}{]}^{T}$$ as the unknown parameters. We select the fundamental frequency $${f}_{0}$$ as a fixed constant initially and we will introduce how to select $${f}_{0}$$ later.

In summary, the GLRT detector adopts the following linear deterministic signal model with unknowns in $$\theta $$:

$s=H\theta \text{,}$

where $$H=[a({f}_{0}),a(2{f}_{0}),a(3{f}_{0})]$$ with $$a({f}_{0})={(1,{e}^{-j2\pi {f}_{0}/{f}_{s}},{e}^{-j4\pi {f}_{0}/{f}_{s}},...,{e}^{-j2\pi (N-1){f}_{0}/{f}_{s}})}^{T}$$ is the observation matrix at a specific fundamental frequency $${f}_{0}$$.

#### Design a GLRT Detector According to the Selected Signal Model

The GLRT detection problem is formulated as

$$\{\begin{array}{cc}{\mathcal{H}}_{0},\phantom{\rule{0.5em}{0ex}}& x=n,\\ {\mathcal{H}}_{1},\phantom{\rule{0.5em}{0ex}}& x=H\theta +n.\end{array}$$

Equivalently, for signal model $s=H\theta \text{,}$ the detection problem is

$$\{\begin{array}{cc}{\mathcal{H}}_{0},\phantom{\rule{0.5em}{0ex}}& A\theta =b,\\ {\mathcal{H}}_{1},\phantom{\rule{0.5em}{0ex}}& A\theta \ne b,\end{array}\phantom{\rule{0.5em}{0ex}}A={I}_{3\times 3},b={0}_{3\times 1}.$$

This is a well-known linear deterministic signal detection problem. The detection statistics of the GLRT detector for complex data is

${T}_{GLRT}(x;{f}_{0})=2\frac{(A{\underset{}{\overset{\u02c6}{\theta}}}_{1}-b{)}^{H}{[A({H}^{H}H{)}^{-1}{A}^{H}]}^{-1}(A{\underset{}{\overset{\u02c6}{\theta}}}_{1}-b)}{{\sigma}^{2}},\phantom{\rule{0.5em}{0ex}}{\underset{}{\overset{\u02c6}{\theta}}}_{1}=({H}^{H}H{)}^{-1}{H}^{H}x.$

For a given probability of false alarm ${P}_{FA}$, the detection threshold of the GLRT detector for complex data is given by

${\gamma}_{GLRT}={Q}_{{\chi}_{2r}^{2}}^{-1}(1-{P}_{FA}),\phantom{\rule{0.5em}{0ex}}r=3\text{.}$

For more information about the GLRT detector, please refer to the documentation page of `phased.GLRTDetector`

.

#### Optimize the Signal Model

Until now, we have designed a GLRT detector for a given fundamental frequency $${f}_{0}$$. However, the fundamental frequency $${f}_{0}$$ is hard to known in practice. As one value of $${f}_{0}$$ corresponds to one signal model, we can formulate multiple signal models with different $${f}_{0}$$ and select the best signal model. According to the GLRT theory, finding the best signal model in this problem is equivalent to finding $${f}_{0}$$ that maximizes the GLRT detection statistics $${T}_{GLRT}(x;{f}_{0})$$, i.e., the optimal $${f}_{0}$$ can be found via solving the following optimization problem:

$$\underset{{f}_{0}}{\mathrm{max}}{T}_{GLRT}(x;{f}_{0}).$$

Let's assume prior knowledge that the fundamental frequency is within 3MHz. We can configure observation matrix $H$ over multiple frequency bins with frequency ranging from 0 to 3MHz and select the optimal frequency bin that maximizes the GLRT detection statistics.

In this example, the GLRT Detector block is used for GLRT detection. The inputs of the GLRT detector are the data $x$, the augmented hypothesis matrix $$[A,b]$$, a set of observation matrices $H$ at different fundamental frequencies, and the known noise power ${\sigma}^{2}$. Run the simulation under the same configuration as the energy detector and the LRT detector. We use the scope to display the detection result over time and display the detection rate. The GLRT detection result shows that although the model order assumption in the GLRT model is inaccurate, the detection rate of the GLRT detector is much higher than that of the energy detector and is also close to the detection rate of the ideal LRT detector.

### Summary

In this example, you learned what an unknown signal detection problem is, how to select a signal model, and how to design and optimize a detector according to the signal model.

### Reference

[1] Steven M. Kay, Fundamentals of Statistical Signal Processing, Detection Theory, 1998

[2] Steven M. Kay, Fundamentals of Statistical Signal Processing, Practical Algorithm Development, 2013