# Fast Two-Step Energy Detection for Spectrum Sensing

Authors: Meiling Lai; Shengliang Peng; Xi Yang; Lin Zhou
Journal: Journal of Electrical and Computer Engineering
 (2015)

---

## Abstract

Spectrum sensing is one of the key tasks in cognitive radio. This paper proposes a fast two-step energy detection (FED) algorithm for spectrum sensing via improving the sampling process of conventional energy detection (CED). The algorithm adaptively selectsN-point or 2N-point sampling by comparing its observed energy with prefixed double thresholds, and thereby is superior in sampling time and detection speed. Moreover, under the constraint of constant false alarm, this paper optimizes the thresholds from maximizing detection probability point of view. Theoretical analyses and simulation results show that, compared with CED, the proposed FED can achieve significant gain in detection speed at the expense of slight accuracy loss. Specifically, within high signal-to-noise ratio regions, as much as 25% of samples can be reduced.


---

## Body

## 1. Introduction

With the rapid growth of wireless communications, the issue of spectrum resource scarcity has been causing deep concern. Cognitive radio (CR) is considered as an efficient approach to solve this problem via opportunistic spectrum access [1, 2]. In CR systems, the secondary user (SU) is not allowed to access the licensed spectrum that is being occupied by a primary user (PU). Otherwise, if no active PU is found, the vacant spectrum can be utilized [3]. Therefore, the task to detect whether the target PU is present or not, namely, spectrum sensing, is of great significance for CR.Three classic spectrum sensing technologies are matched filter detection (MFD), cyclostationary feature detection (CFD), and energy detection (ED). MFD is viewed as the most accurate method but requires detailed prior knowledge of PU signal [4]. CFD performs reliably even with very low signal-to-noise ratio (SNR), while its computational complexity is a bottleneck [5]. Compared with them, ED does not require any prior information and consumes little calculation [6] and thereby is widely applied to detect PU.ED suffers from server performance degradation at low SNR [6]. To improve its performance, [7–9] present some ED-CFD hybrid schemes that firstly perform ED to search for PU and then reuse the observations to conduct CFD if target PU is not detected by ED. These schemes can achieve better performance under awful noise conditions, while their complexity is high because of CFD. To solve this problem, [10–12] consider performing ED twice to avoid CFD. In [10], two thresholds are preset and decisions are made directly in case that the observed energy is either large enough or small enough. Otherwise, the second ED is implemented additionally. This method can improve detection accuracy to some extent but is sensitive to noise uncertainty. An adaptive double-threshold energy detection (AED) method is proposed in [11], which adjusts its thresholds according to SNR to combat noise uncertainty. It should be pointed out that these methods are all committed to improve detection accuracy, while ignoring the importance of detection time. Reference [12] investigates the detection accuracy of AED and analyzes its detection time, indicating that the former is improved at the cost of the latter. Since long detection time impairs system throughput and agility [13], it is necessary to dig into the issue of fast ED.As is known, the whole detection comprises sampling and calculation processes. Due to the reasons that calculation in ED is rather simple and time required by this process can be neglected, given certain sampling frequency, detection time of ED is mainly determined by its sampling number [14]. In this paper, a fast two-step ED (FED) scheme is proposed via improving the sampling process of conventional energy detection (CED) and reducing its sampling number. This new scheme can achieve great gain in detection speed at the expense of slight accuracy loss. The rest of our paper is organized as follows. CED is briefly introduced in Section 2. In Section 3, FED is discussed and its performance is analyzed. A method to determine the optimal thresholds is also provided. Simulation results are presented in Section 4 and conclusions are drawn in Section 5.


## 2. Conventional Energy Detection

In CED, whether a target PU is present is determined by comparing the received energy with the preset thresholds, which can be modeled as a binary hypothesis described as(1)
y
k
=
n
k
H
0
s
k
+
n
k
H
1
,where y
(
k
) represents the received signal at SU’s receiver; s
(
k
) and n
(
k
) denote the PU signal and the additive noise, respectively; H
1 and H
0 stand for the hypotheses of PU’s presence and absence, respectively. In this case, the test statistic of CED is given by (2)
V
=
∑
k
=
1
n
y
(
k
)
2
,where V denotes the received energy and n means the sampling number.Assume the noise is AWGN with zero mean and unit variance and PU transmits constant-power signal. Sincen is usually very large, V approximately follows Gaussian distributions [15]:(3)
V
~
N
(
n
,
2
n
)
H
0
N
n
1
+
γ
,
2
n
(
1
+
2
γ
)
H
1
,where γ is the received SNR measured by SU.In CED, SU can make decisions on whether PU is present or not (H
1 or  H
0) as follows:(4)
if
V
≥
λ
H
1
if
V
<
λ
H
0
,where λ is the preset decision threshold.The detection accuracy of CED is usually evaluated in terms of two metrics, namely, the false alarm probability (P
f) and the detection probability (P
d):(5)
P
f
=
P
V
≥
λ
∣
H
0
=
∫
λ
∞
f
V
∣
H
0
d
v
,
P
d
=
P
V
≥
λ
∣
H
1
=
∫
λ
∞
f
V
∣
H
1
d
v
,where f
V
∣
H
0 and f
V
∣
H
1 are the conditional probability density functions of V under hypotheses H
0 and H
1, respectively. According to (3), we can rewrite the probabilities as(6)
P
f
=
Q
λ
-
n
2
n
,
P
d
=
Q
λ
-
n
1
+
γ
2
n
1
+
2
γ
,where Q
x
=
∫
x
∞
(
1
/
2
π
)
e
-
t
2
/
2
d
t is the Q-function.As for the detection time, since the time required for calculation is negligible, it is mainly determined by the sampling number:(7)
T
d
=
n
f
S
,where f
S is the sampling frequency. In the rest of this paper, we will discuss the sampling number n instead of the detection time T
d for simplicity.


## 3. Fast Two-Step Energy Detection

### 3.1. Algorithm Description

FED is proposed based on CED. Assume2
N samples are collected to calculate energy in CED (n
=
2
N). We equally divide the samples into two parts, as illustrated in Figure 1(b). By comparing its observed energy with the preset thresholds, FED adaptively chooses N-point or 2
N-point sampling.Figure 1
Sampling process of CED and FED.
(a)
CED
(b)
FEDThe algorithm of FED is detailed as follows: two thresholdsλ
1 and λ
2
λ
1
>
λ
2 are preset initially. At the first step, N samples are gathered to measure the received energy V
1. If V
1 is high enough and greater than λ
1, hypothesis H
1will be accepted directly. Otherwise, the second step will be performed:(8)
if
V
1
≥
λ
1
accept
H
1
if
V
1
<
λ
1
do
the
second
step
.At the second step, other N samples will be collected to calculate the received energy V
2. If the average value of V
1 and V
2 is greater than λ
2, H
1 will be accepted. Otherwise, H
0 will be accepted:(9)
the
second
step
if
V
1
+
V
2
2
≥
λ
2
accept
H
1
if
V
1
+
V
2
2
<
λ
2
accept
H
0
.


### 3.2. Detection Accuracy Analysis

LetP
f
1 and P
f
2 denote the false alarm probabilities at the first and the second steps of FED and P
d
1 and P
d
2 represent the corresponding detection probabilities at two steps, respectively. Then we have(10)
P
f
1
=
P
V
1
≥
λ
1
∣
H
0
=
Q
λ
1
-
N
2
N
,
P
f
2
=
P
V
1
+
V
2
2
≥
λ
2
∣
H
0
=
Q
λ
2
-
N
N
,
P
d
1
=
P
V
1
≥
λ
1
∣
H
1
=
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
,
P
d
2
=
P
V
1
+
V
2
2
≥
λ
2
∣
H
1
=
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
.Note that N is the sampling number of each step.According to the algorithm, final false alarm probability and final detection probability of FED, namely,P
f and P
d, can be formulated as(11)
P
f
=
P
f
1
+
1
-
P
f
1
·
P
f
2
,
P
d
=
P
d
1
+
1
-
P
d
1
·
P
d
2
.Substituting (10) into (11), we get (12)
P
f
=
Q
λ
1
-
N
2
N
+
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
,
P
d
=
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
+
1
-
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
·
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
.


### 3.3. Optimization of Double Thresholds

As shown in (12), detection accuracy is closely related to λ
1 and λ
2. In this subsection, we deduce the optimal double thresholds via maximizing P
d for a given P
f. The optimization problem can be described as(13)
Max:
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
+
1
-
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
·
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
(14)
Subject
to:
Q
λ
1
-
N
2
N
+
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
=
β
,where β is the predetermined false alarm probability.This conditional extreme value model can be solved by Lagrange multiplier method. Define the following:(15)
g
λ
1
,
λ
2
=
β
-
Q
λ
1
-
N
2
N
-
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
.Then the Lagrange function is(16)
f
λ
1
,
λ
2
,
c
=
P
d
λ
1
,
λ
2
+
c
·
g
λ
1
,
λ
2
,where c is a constant. Rewriting P
d
λ
1
,
λ
2 and g
λ
1
,
λ
2 with the error function erf
⁡
⁡
x
=
1
-
2
Q
(
2
x
), we can get(17)
f
λ
1
,
λ
2
,
c
=
3
4
-
1
4
erf
⁡
⁡
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
-
1
4
erf
⁡
⁡
λ
2
-
N
1
+
γ
2
N
1
+
2
γ
-
1
4
erf
⁡
⁡
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
erf
⁡
⁡
λ
2
-
N
1
+
γ
2
N
1
+
2
γ
+
c
1
4
erf
⁡
⁡
λ
1
-
N
2
N
+
1
4
erf
⁡
⁡
λ
2
-
N
2
N
+
1
4
erf
⁡
⁡
λ
1
-
N
2
N
erf
⁡
⁡
λ
2
-
N
2
N
-
3
4
+
β
.Taking the first-order partial derivative of (17) with respect to λ
1 and λ
2, respectively,(18)
∂
f
λ
1
,
λ
2
,
c
∂
λ
1
=
0
,
(19)
∂
f
λ
1
,
λ
2
,
c
∂
λ
2
=
0
,and combining (18) and (19) to eliminate c, we can get the relationship between λ
1 and λ
2:(20)
1
+
erf
⁡
⁡
(
λ
1
-
N
1
+
γ
)
/
2
N
1
+
2
γ
1
+
erf
⁡
⁡
(
λ
1
-
N
)
/
2
N
·
e
(
-
2
γ
λ
1
2
+
2
N
γ
λ
1
+
N
2
γ
2
)
/
4
N
1
+
2
γ
=
1
+
erf
⁡
⁡
(
λ
2
-
N
1
+
γ
)
/
2
N
1
+
2
γ
1
+
erf
⁡
⁡
(
λ
2
-
N
)
/
2
N
·
e
(
-
2
γ
λ
2
2
+
2
N
γ
λ
2
+
N
2
γ
2
)
/
2
N
1
+
2
γ
.Moreover, based on (14), another equation can be obtained as(21)
λ
1
=
N
+
2
N
Q
-
1
β
-
Q
(
λ
2
-
N
)
/
N
1
-
Q
(
λ
2
-
N
)
/
N
.Consequently, given the parametersN, γ, and β, the optimal λ
1 and λ
2 can be deduced according to (20) and (21). Based on these two thresholds, we can maximize detection probability subject to certain false alarm probability.


### 3.4. Average Sampling Number Analysis

The proposed FED scheme adaptively choosesN-point or 2
N-point sampling. Let P
0 and P
1 represent the prior probabilities of hypotheses H
0 and H
1, respectively. Then the average sampling number of FED can be expressed as(22)
N
~
=
N
P
0
·
P
f
1
+
P
1
·
P
d
1
+
2
N
P
0
·
1
-
P
f
1
+
P
1
·
1
-
P
d
1
.Without loss of generality, assumeP
0
=
P
1
=
0
.
5 in this paper. Then we have(23)
N
~
=
N
2
4
-
P
f
1
-
P
d
1
.Since 0
<
P
f
1
+
P
d
1
<
1 [16], the bounds of average sampling number in FED are given by(24)
1.5
N
<
N
~
<
2
N
.Note that CED always performs2
N-point sampling. So FED certainly collects fewer samples and is faster than CED. In addition, as much as 25% of samples and detection time can be reduced at most compared with CED.


## 3.1. Algorithm Description

FED is proposed based on CED. Assume2
N samples are collected to calculate energy in CED (n
=
2
N). We equally divide the samples into two parts, as illustrated in Figure 1(b). By comparing its observed energy with the preset thresholds, FED adaptively chooses N-point or 2
N-point sampling.Figure 1
Sampling process of CED and FED.
(a)
CED
(b)
FEDThe algorithm of FED is detailed as follows: two thresholdsλ
1 and λ
2
λ
1
>
λ
2 are preset initially. At the first step, N samples are gathered to measure the received energy V
1. If V
1 is high enough and greater than λ
1, hypothesis H
1will be accepted directly. Otherwise, the second step will be performed:(8)
if
V
1
≥
λ
1
accept
H
1
if
V
1
<
λ
1
do
the
second
step
.At the second step, other N samples will be collected to calculate the received energy V
2. If the average value of V
1 and V
2 is greater than λ
2, H
1 will be accepted. Otherwise, H
0 will be accepted:(9)
the
second
step
if
V
1
+
V
2
2
≥
λ
2
accept
H
1
if
V
1
+
V
2
2
<
λ
2
accept
H
0
.


## 3.2. Detection Accuracy Analysis

LetP
f
1 and P
f
2 denote the false alarm probabilities at the first and the second steps of FED and P
d
1 and P
d
2 represent the corresponding detection probabilities at two steps, respectively. Then we have(10)
P
f
1
=
P
V
1
≥
λ
1
∣
H
0
=
Q
λ
1
-
N
2
N
,
P
f
2
=
P
V
1
+
V
2
2
≥
λ
2
∣
H
0
=
Q
λ
2
-
N
N
,
P
d
1
=
P
V
1
≥
λ
1
∣
H
1
=
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
,
P
d
2
=
P
V
1
+
V
2
2
≥
λ
2
∣
H
1
=
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
.Note that N is the sampling number of each step.According to the algorithm, final false alarm probability and final detection probability of FED, namely,P
f and P
d, can be formulated as(11)
P
f
=
P
f
1
+
1
-
P
f
1
·
P
f
2
,
P
d
=
P
d
1
+
1
-
P
d
1
·
P
d
2
.Substituting (10) into (11), we get (12)
P
f
=
Q
λ
1
-
N
2
N
+
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
,
P
d
=
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
+
1
-
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
·
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
.


## 3.3. Optimization of Double Thresholds

As shown in (12), detection accuracy is closely related to λ
1 and λ
2. In this subsection, we deduce the optimal double thresholds via maximizing P
d for a given P
f. The optimization problem can be described as(13)
Max:
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
+
1
-
Q
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
·
Q
λ
2
-
N
1
+
γ
N
1
+
2
γ
(14)
Subject
to:
Q
λ
1
-
N
2
N
+
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
=
β
,where β is the predetermined false alarm probability.This conditional extreme value model can be solved by Lagrange multiplier method. Define the following:(15)
g
λ
1
,
λ
2
=
β
-
Q
λ
1
-
N
2
N
-
1
-
Q
λ
1
-
N
2
N
·
Q
λ
2
-
N
N
.Then the Lagrange function is(16)
f
λ
1
,
λ
2
,
c
=
P
d
λ
1
,
λ
2
+
c
·
g
λ
1
,
λ
2
,where c is a constant. Rewriting P
d
λ
1
,
λ
2 and g
λ
1
,
λ
2 with the error function erf
⁡
⁡
x
=
1
-
2
Q
(
2
x
), we can get(17)
f
λ
1
,
λ
2
,
c
=
3
4
-
1
4
erf
⁡
⁡
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
-
1
4
erf
⁡
⁡
λ
2
-
N
1
+
γ
2
N
1
+
2
γ
-
1
4
erf
⁡
⁡
λ
1
-
N
1
+
γ
2
N
1
+
2
γ
erf
⁡
⁡
λ
2
-
N
1
+
γ
2
N
1
+
2
γ
+
c
1
4
erf
⁡
⁡
λ
1
-
N
2
N
+
1
4
erf
⁡
⁡
λ
2
-
N
2
N
+
1
4
erf
⁡
⁡
λ
1
-
N
2
N
erf
⁡
⁡
λ
2
-
N
2
N
-
3
4
+
β
.Taking the first-order partial derivative of (17) with respect to λ
1 and λ
2, respectively,(18)
∂
f
λ
1
,
λ
2
,
c
∂
λ
1
=
0
,
(19)
∂
f
λ
1
,
λ
2
,
c
∂
λ
2
=
0
,and combining (18) and (19) to eliminate c, we can get the relationship between λ
1 and λ
2:(20)
1
+
erf
⁡
⁡
(
λ
1
-
N
1
+
γ
)
/
2
N
1
+
2
γ
1
+
erf
⁡
⁡
(
λ
1
-
N
)
/
2
N
·
e
(
-
2
γ
λ
1
2
+
2
N
γ
λ
1
+
N
2
γ
2
)
/
4
N
1
+
2
γ
=
1
+
erf
⁡
⁡
(
λ
2
-
N
1
+
γ
)
/
2
N
1
+
2
γ
1
+
erf
⁡
⁡
(
λ
2
-
N
)
/
2
N
·
e
(
-
2
γ
λ
2
2
+
2
N
γ
λ
2
+
N
2
γ
2
)
/
2
N
1
+
2
γ
.Moreover, based on (14), another equation can be obtained as(21)
λ
1
=
N
+
2
N
Q
-
1
β
-
Q
(
λ
2
-
N
)
/
N
1
-
Q
(
λ
2
-
N
)
/
N
.Consequently, given the parametersN, γ, and β, the optimal λ
1 and λ
2 can be deduced according to (20) and (21). Based on these two thresholds, we can maximize detection probability subject to certain false alarm probability.


## 3.4. Average Sampling Number Analysis

The proposed FED scheme adaptively choosesN-point or 2
N-point sampling. Let P
0 and P
1 represent the prior probabilities of hypotheses H
0 and H
1, respectively. Then the average sampling number of FED can be expressed as(22)
N
~
=
N
P
0
·
P
f
1
+
P
1
·
P
d
1
+
2
N
P
0
·
1
-
P
f
1
+
P
1
·
1
-
P
d
1
.Without loss of generality, assumeP
0
=
P
1
=
0
.
5 in this paper. Then we have(23)
N
~
=
N
2
4
-
P
f
1
-
P
d
1
.Since 0
<
P
f
1
+
P
d
1
<
1 [16], the bounds of average sampling number in FED are given by(24)
1.5
N
<
N
~
<
2
N
.Note that CED always performs2
N-point sampling. So FED certainly collects fewer samples and is faster than CED. In addition, as much as 25% of samples and detection time can be reduced at most compared with CED.


## 4. Simulation Results

In this section, simulation results are provided to verify the FED algorithm and its theoretical conclusions.Figures2 and 3 show final false alarm probability and detection probability of FED algorithm versus λ
2, respectively. Simulation settings are P
0
=
0.5, γ
=
-
5
dB, N
=
100 [17], and β
=
0.1
,
0.05
,
0.0
1. For any given λ
2, corresponding λ
1 is obtained according to (21). As shown in Figure 2, final false alarm probability is always equal to β. In other words, a pair of thresholds satisfying (21) ensures that the constraint on false alarm probability is met. In Figure 3, the optimal λ
2
(
115.0
,
118.3
,
124.6
), which is derived from (20) and (21), is marked on the x-axis. Since final detection probability achieves maximum values with the optimal λ
2 as expected, the effectiveness of (20) and (21) is certainly verified.Figure 2
Final false alarm probability versusλ
2 under different β.Figure 3
Final detection probability versusλ
2 under different β.In order to evaluate the performances of CED and FED, Figure4 plots their detection probabilities and average sampling numbers versus SNR under different false alarm constraints β
=
0.1
,
0.05
,
0.01 with P
0
=
0.5 and N
=
100. According to the top subfigure of Figure 4, in spite of the fact that detection probability of FED is slightly lower, two detection probability curves almost coincide, indicating that detection accuracy of CED and FED is approximately the same. As shown in the bottom subfigure of Figure 4, CED consistently takes 200-point sampling, while the sampling number of FED is between 150 and 200. Since its sampling number is reduced, FED requires less sampling time and completes the detection faster.Figure 4
Performance of CED and FED versusγ under different β.In Figure5, the average sampling number of CED and FED is detailedly compared under different N to highlight the superiority of the latter. It can be seen from this figure that, no matter how N changes, the sample number of CED is always 2
N and that of FED varies from 1.5
N to 2
N, which agrees well with (24). Specifically, in the scenarios with high SNR (SU is close to the PU transmitter), 0.5
N samples are reduced and as much as 25% of detection time can be saved.Figure 5
Comparison of average sampling number under differentN.To demonstrate the effect ofP
0 on detection performance, Figure 6 plots detection probabilities as well as average sampling numbers of CED and FED versus SNR under different prior probabilities P
0
=
0.1
,
0.5
,
0.9. According to the top subfigure of Figure 6, detection probabilities of these two algorithms are little affected by P
0, while in the bottom subfigure of Figure 6, we can see that the sample number of CED is always 2
N and that of FED increases as P
0 increases. The reason is that higher P
0 means larger possibility of PU’s absence, and FED prefers taking 2
N-point sampling when PU is absent.Figure 6
Performance of CED and FED versusγ under different P
0.


## 5. Conclusions

A FED scheme for spectrum sensing is proposed via improving the sampling process of CED. Detection accuracy of this new scheme is analyzed. Moreover, we deal with the optimization problem and provide a method to deduce its optimal double thresholds. The average sampling number of FED is also discussed. We prove that, compared with CED, the proposed FED certainly uses fewer samples and 25% of samples can be reduced at most with high SNRs.



---

*Source: 591627-2015-03-30.xml*