An analysis of energy detector based on improved approximations of the chi-square distributions

Closed-form expressions for the detection probability, the false alarm probability and the energy detector constant threshold are derived using approximations of the central chi-square and non-central chi-square distributions. The approximations used show closer proximity to the original functions when compared to the expressions used in the literature. The novel expressions allow gains up to 6% and 16% in terms of measured false alarm and miss-detection probability, respectively, if compared to the Central Limit Theorem approach. The throughput of cognitive network is also enhanced when these novel expressions are implemented, providing gains up to 9%. New equations are also presented that minimize the total error rate to obtain the detection threshold and the optimal number of samples. The analytical results match the results of the simulation for a wide range of SNR values.

second interval: transmission of information or remain in standby. The optimal duration of the sensing interval was studied in [3] where it was theoretically shown that there is an ideal detection sensing interval duration that maximizes the cognitive radio network (CRN) throughput. In that work, the Gaussian approach, or central limit theorem (CLT) approach was used when assuming a large number of samples in the sensing interval [4].
The method presented in [5] also employs energy detection and analyzes the optimal sensing duration but different from [3], it assumes that the PU has a variable occupation for the full duration of the frame. In [6] a cognitive radio analysis is given for the design of codes in the finite blocklength regime and energy detection with the CLT approach is also used. In [7] the compromise between sensing and energy efficiency of the CRN is analyzed through the introduction of two models: channel handoff and stop-and-wait. The hidden terminal problem is investigated in [8] in a joint analysis of energy detection and Hidden Markov model.
Cooperation between SUs is addressed in [9] where a threshold optimization is developed estimating the energy of the primary signals based on a finite number of samples. The cooperation is also studied in [10], where the energy detector is used together with signal correlation analysis to improve the performance of the entire network. Cooperation is also verified in [11], this work takes into account the impact of multiple SUs and PUs accessing the network, which reduces the network throughput, in addition the compromise problem between sensing and throughput is redefined using the PU interference probability.
The performance of the energy detector is also investigated in [12], where an adaptive detection threshold is proposed to improve the sensing performance. The energy detector also serves as basis for the work of [13], which uses the approximations found in [3] and an approach based on state transitions to generate new expressions for the detection and false alarm probabilities, allowing simultaneous analysis of the problem between sensing and flow for high activity PU.
The Gaussian approach to the energy detector is also studied in more recent works. The authors of [14] present an adaptive interval sensing algorithm where a discrete gain is obtained. In [15] a cooperative analysis is presented considering some models of fading channels. In [16] an energy detector with two dynamic thresholds is used to optimize signal detection. The energy detection threshold is also studied in the work of [17] which proposes an algorithm to select the optimum threshold providing improved throughput. Finally, in [18] a reinforcement learning-based multi-slot double-threshold spectrum sensing with Bayesian fusion is proposed to sense big spectrum data, which can find required idle channels faster while guaranteeing spectrum sensing performance. The authors of [19] developed a multi-hypothesis test perspective for illegitimate access and rogue power emission in cognitive radio scenarios. This work provides a comprehensive mathematical analysis concerning energy detection based on central and non-central chi-square distributions.

System model
In the proposed system model we assume a pair of PU transceiver and a pair of SU transceiver, and the PU receiver is within the range of the SU transmitter. We also are assuming single band detection.
As mentioned before the PU has higher priority and SU transmissions could not impact the PU link. To achieve this restriction the SU senses spectrum periodically, this cycle is known as SU frame and it is divided into two intervals which are repeated after a time T. In the first interval of the frame, SU performs sensing and based on the result, it can execute two actions: transmitting information or remaining in standby. The sensing time is denoted as τ S .
The probability associated with the activity of PU (traffic density) is denoted as P(H 0 ) where no transmissions are made or P(H 1 ) if the PU is definitely using the channel. We also assume that the PU activity remains constant throughout the sensing period. Figure 1 shows the proposed system model and the SU frame with the sensing interval.

Energy detector
Spectral sensing can be implemented by several methods found in the literature, such as energy detection, matched filter and cyclostationary feature detection. The energy detector, first introduced in [2], is the simplest and most effective technique, and the output is proportional to the energy of the received signal.
The energy detector implemented in the SU is detailed in Fig. 2, where samples of the received signal passes through a squared lift device followed by an integrator, the output is compared with a threshold value. The result can be presented as a binary hypothesis, the occupation or the vacancy of the spectrum [3]: Fig. 1 a System model. b SU frame [3,17] where n(t) represents the noise at the detector input, sampled at time t, h is the channel gain, x(t) is the PU's signal and y(t) is the signal received at the SU. Under the hypothesis H 0 only the noise is present in the SU receiver, while in the hypothesis H 1 the PU signal is present on the SU side. The energy detector collects a total number of N samples to perform the hypothesis test.
Noise samples n(t) are assumed to be AWGN with zero mean and variance σ 2 n [3]. The SNR between PU and SU, measured at the SU's receiver, is given by γ = x is the variance of x(t). The received signal y(t) passes through the energy detector and the detector output is used to determine the test statistic, . The detection probability P d and the false alarm probability P f are defined according to the test statistic as [4]: where th is the detection threshold value. The test statistic follows different probability density functions when analyzed under hypotheses H 0 e H 1 , being denoted as f �|H 0 ( ) and f �|H 1 ( ) , respectively. Thus, P f is the probability that the energy detector identify the existence of signal, which actually, is not present at the receiver input. Besides, P d is the probability that the energy detector assigns the presence of a signal and the signal actually exists. Another parameter that is also defined in [2] is the miss-detection probability P md = 1 − P d which is the probability that the energy detector does not identify the presence of a signal; however, it is present at the receiver input. This study did not take into account the fading, thus h = 1.
Regarding hypothesis H 0 , the test statistic, , is the result of a sum of 2N squares of independent Gaussian random variables. The output of the energy detector therefore follows a central chi-square distribution ( χ 2 ), with ν degrees of freedom, whose probability density function (PDF) is [20]: where Ŵ(a) = ∞ 0 b a−1 e −b db is the gamma function. The false alarm probability is defined through (2), i.e. it is the complementary cumulative distribution function (CDF) of the central chi-square distribution, as: where F �|H 0 ( ) is the CDF of a random variable with central chi-square distribution [20]: The function γ L (a, b) = b 0 c a−1 e −c dc is the lower incomplete gamma function. The central chi-square distribution tends toward the normal distribution when ν → ∞ . In this case the CLT approach is used [20] to give: where denotes the CDF of the normal distribution. According to [4], = th σ 2 n and ν = 2N , so (4) can be rewritten [3], just replacing the variables: The function Q(a) = 1 − �(a) is known as the Gaussian-Q function and represents the tail of the standard normal distribution. The superscript (CLT) in (6) and (8) identify the use of the CLT approach. As indicated in Sect. 1, Eq. (8) is widely used in the energy detector, as can be seen in [3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18]. However, as presented in [21], the CLT approach is not very accurate unless N is very large.

Throughput analysis
The network throughput is defined as the ratio between the total transmitted data and the total consumed time. If the channel is sensed busy, the SU will not transmit data and the throughput will be zero. If the channel is sensed idle and the real state of the channel is also unoccupied, the throughput will be equal to [17]: where α = T −τ S T and γ S is the the SNR between the SU transmitter and the SU receiver. If the channel is sensed as idle but its real state is busy, then the throughput will be reduced because there will be interference in the channel, as follows: The total average throughput for the cognitive network is: where P(H 0 ) and P(H 1 ) are the probabilities of PU activity (traffic density) defined in Sect. 1.2.

Motivation and objectives
Thus far, works [3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18] use the energy detector with the CLT approach. Low signal-tonoise ratio (SNR) scenarios require the energy detector to analyze a large number of samples to perform well. When the number of samples is very large, the probability distribution of the sum of these random variables with finite mean and variance is close to the normal distribution. However, in some cases, this approach does not prove to be the most appropriate, especially for scenarios where the number of samples is restricted (SNR design next to 0 dB). As shown in [6], when finite blocklength communications are analyzed, the number of samples is very small. Moreover, analysis of sensor networks shown in [23,24] also used a small amount of samples.
This study is motivated by the fact that the previous work on the subject focused on the design of the energy detector using a large number of samples. As far as we know, the literature is scarce in addressing the design of the energy detector for a small number of samples. As the output of the energy detector has characteristics of the central chi-square and non-central chi-square distributions, some expressions of classical approximations found in the literature are used to formulate new expressions for the energy detector. It was possible to find expressions that are more appropriate for scenarios that demand a moderate amount of samples, these expressions have a better fit than CLT approach expressions. It is also assumed that the PU signal samples are Gaussian.
The contributions of this work are described below: • Derivations of approximated expressions for the detection probability and the false alarm probability for the energy detector. • Derivation of new expressions to evaluate the constant threshold based on the approximations.
Simulations performed show the use of new expressions presented achieve gains nearly 6% in terms of measured false alarm probability and nearly 16% in terms of miss-detection probability. Simulations also show gains up to 9% in terms of throughput when novel expression is used in comparison with CLT approach. The rest of this work is divided as follows. Section 2 introduces the proposed improvements. Section 3 presents the results of the simulations. Finally, in Sect. 4, some conclusions are discussed.

Methods/experimental
The research content of this article is divided into two parts, the first being a theoretical analysis of approximations of probability distributions, in the second part through the expressions computational simulations were performed with the MATLAB ® 2018 software from the company Mathworks ® .

Novel energy detector metrics
The classical literature presents some approximate equations for solving (5) such as Fisher's approximation [25]: In this case, the false alarm probability can be determined with a new expression. For this procedure we just replace the variables = th σ 2 n and ν = 2N in (17): where the index F indicates the Fisher approximation. Another approach to (5) was introduced by Wilson-Hilferty [26]: Again replacing the aforementioned variables and ν we get this expression: where the index WH indicates the Wilson-Hilferty approach to differentiate the expression. Approximations for the CDF of the non-central chi-square distribution are also found in the literature, such as the Abdel-Aty approach [27]: where f = (ν+ϕ) 2 ν+2ϕ . Knowing that ϕ = 2N γ , the detection probability can be rewritten with the substitution of the variables in (21), generating: where the index AA indicates Abdel-Aty's approach.
It is also possible to use the Sankaran approach [28] for the CDF of the non-central chisquare distribution: . In this case the detection probability can be rewritten using (24) and the variables aforementioned, where the index S indicates the use of the Shankaran approach, generating expression:

Constant threshold design
The performance of the energy detector is highly impacted by the correct choice of parameters that generate the equations presented in Sect. 2.2. One procedure to establish an excellent sensing performance is the specification of constant parameters in practical energy detection design. The design parameters are the constant values P f and P d or P md , where P md = 1 −P d , defined for a certain project SNR, γ . The definition of established parameters generates a constant threshold ˆ th [12,17].
According to [3,17], the threshold can be selected with constant detection rate (CDR) or constant false alarm rate (CFAR) based on the CLT approach. The CFAR threshold requires a constant false alarm probability [17]: th In CDR approach the miss-detection probability is constant [17]: The optimum number of samples N * for some specific parameters can be defined combining the CLT expressions (25) and (26) (18) can be arranged with constant false alarm probability, inverting (18) in respect to P f , in this expression: Also setting a constant false alarm probability in (20) and inverting this expression we obtain: Equation (22) can be also arranged with respect to the constant miss-detection probability, fixing P md in (22), resulting in: Finally, it is possible to define the fixed threshold project based on (24), with a fixed miss-detection probability as in the expression (31): The expressions (28) and (29) are alternative representations to the CFAR-CLT approach (25). Expressions (30) and (31) are an alternative form to the CDR based on CLT approach (26). The novel expressions presented in this work achieve more accurate results as will be explored in Sect. 3. In addition to the constant threshold design, the equations can be adjusted to define the number of samples N for convenient detection. Another important analysis resulting from the energy detector parameters is the total error probability P e = P f + P md , which indicates the expectation of inaccuracy of the energy detector. If the total error probability is evaluated based on th , it has (26) th a global minimum, which indicates that there is only one value of th minimizing P e , that is, there is an optimal threshold * th , such that * th = arg min th (P e ) , this is [29], To achieve this result, we chose a novel expression of false alarm probability (18)  To solve the derivative we use the identity: the partial derivative of P F f in relation to th is given by the expression: Equation (22) can be in terms of P md and the error function as: The partial derivative of P AA md in relation to th can be achieved using the identity: Finally, the partial derivative of P AA md in relation to th is given by the original equation: In this way, either the optimal detection threshold or the optimum number of samples can be found numerically through the resolutions of Eqs. (35) and (38).

Results and discussion
The analytical results presented in the previous section are discussed together with results obtained from computer simulations. Figure 3 shows different measures of P d as a function of P f , or P d = f (P f ) , through receiver operating characteristic curves (ROC) which allow to evaluate the performance of the energy detector based on the theoretical and approximate expressions of the probabilities presented in Sect. ) also obtained by combining the novel expressions (20) and (24).
As there were two expressions of P d and two of P f in Sect. 2.2, four new ROC curves could be generated only with the alternative approaches; however, it was decided to choose the presentation of only two new ROC curves for a more concise graphical analysis. In this sense, the chosen pairs were P AA ) . The closer to the upper left corner the ROC curve is, the better its performance as it provides a higher P d with a lower P f . The increase of N is a way to improve the performance of the ROC curve, graphically we can see that all curves tend to match when we increase the value of N. Through the analysis of Fig. 3 it is possible to verify that the curve generated through the CLT approach, besides having a significant distance in relation to the original curves, also has a lower performance compared to the curves generated by the proposed approximations. It is possible to observe, therefore, that the alternative approaches to the CLT approach are more accurate in relation to the original curve. Figure 4 presents the measured false alarm probability and detection probability as functions of γ obtained through simulations. The energy detection employs the fixed threshold schemes presented in Sect. 2.3. In all simulations, the optimum number of samples N is calculated according to (27) for each value of γ . For the analysis of the fixed threshold design we choose two scenarios. In the first scenario PU is not present and only noise is considered at the SU radio input, the fixed threshold schemes used in this case are based on constant false alarm rate (CFAR), given by the expressions (25), (28) and (29).
In the second scenario PU is present, the fixed threshold schemes used in this instance are based on constant detection rate (CDR), given by the expressions (26), (30) and (31). The aim of each scenario is to measure P f for the first scenario or P md for the second scenario. In the first scenario, the design signal-to-noise ratio value ( γ ) is used only as a parameter for the energy detector design as it is necessary to estimate the number of samples. Figure 4 shows the measured false alarm probability P f or miss-detection probability P md as a function of several values of γ . It was performed a total of N a = 20,000 rounds of simulation and was considered σ n = √ 1/2 . For the different values of γ analyzed, fixed project values P f = 0.1 and P d = 0.9 were kept. It is possible to verify that the results for low values of γ ( N >> 1 ) are very similar in all six simulations. In the region − 20 dB <γ < −8 dB , the values of P f measured in the SU are really close to the project values P f . Also in Fig. 4, for γ > −8 dB it is possible to observe a difference between measured values of P f and P md for all approaches employed. However, there is a greater gap between the measured values of P f using the CLT approach compared to the project value P f and also with the values measured by the other approaches. A major difference can be observed between the measured values P md using the CLT approach and the project value P md . The overall performance of the energy detector with the fixed thresholds presented in (28) and (29) shows closer proximity to P f in comparison with the CLT approach (25). For γ = 0 dB the project with CFAR−CLT th shows a difference about 6% compared to the project CFAR−WH th . The performance of the energy detector in the second scenario with the constant thresholds presented in (30) and (31) also shows closer proximity to P md . For γ = 0 dB the project with CDR−CLT th shows a difference about 16% compared to the project . These differences occur because for the same number of samples defined in the project, the false alarm probabilities and miss-detection probabilities have different values as can be seen in Fig. 3.
Some constant threshold expressions presented in this work are more complex than those based on the CLT approach, but we can see that they bring benefits in terms of energy detector performance. In order to analyze the computational complexity when using these expressions, the empirical complexity measuring method of [30] was used, which measures the computer workload in terms of time spent. In Fig. 5, each bar represents the measured computational complexity relative to the CLT-based expressions. In Fig. 5a, comparisons are based on the CFAR expressions: (25), (28) and (29). In Figure 5b, comparisons are made with the CDR expressions: (26), (30) and (31). From Fig. 5a it can be seen that the expression based on the Wilson-Hilferty approach is approximately 50% more costly when compared to the CLT approach. On the other hand, when the Fisher's approximation is used, there is a gain of approximately 6% in terms of computational effort. Figure 5b shows that both approaches used (Abdel-Aty and Sankaran) demand a greater computational effort when compared to the CLT approach. The expression based on the Abdel-Aty approach is approximately 94% more costly than the CLT-based expression while the CDR-based Sankaran expression is 345% more costly than the CLT-based expression. Although this difference appears to be very large, it should be noted the gain, in terms of performance of the energy detector, which the use of these expressions provides. It is important to emphasize that the computational cost is not demanded continuously when the SU performs sensing. In practical implementation based on constant detection threshold the SU makes use of these expressions only in the definition of the project for a given set of parameters. Thus, for a given environment, the SU calculates the constant detection threshold once and then configures its internal circuits for boundlessness sensing intervals. Figure 6 shows the total error probability P e = P f + P md simulated, using two approaches: original equations and approximations presented in Sect.  the higher the values of th and N, as expected. It can also be observed that the approximations proposed in this work are properly adjusted to the curves of the original equations. The differences in terms of the number of samples N and the optimal detection threshold level were less than 1% , when compared with the original functions and the proposed total error probability model, thereby showing the accuracy of the results obtained. Figure 7 shows the measured false alarm probability and detection probability as functions of γ . In this scenario we verified the proposed constant threshold design for a wide range of SNR; however, the same number of samples N = 50 is kept for each SNR value evaluated. The design parameters were set to P d = 0.9 and P f = 0.1 , which represents γ ≈ −4 dB , with the limited number of samples. The curves generated by the simulation were obtained first by finding the constant threshold values for each of the approaches presented, expressions (25)(26)(27)(28)(29)(30)(31). For all CFAR approaches, the P f value is constant and equal to P f , the same occurs for all the CDR approaches, the P d value is also constant and equal to P d . In addition, for each CDR threshold value, the false alarm probabilities are calculated, therefore expression (8) is calculated with respect to (26), (18) is calculated using (30) and (20) is calculated with (31). For each CFAR threshold value, the detection probabilities are calculated; hence, expression (13) is calculated using (25), (22) is calculated with (28) and (24) is calculated with respect to (29).
It can be observed in Fig. 7 that evaluating several SNR values and keeping the same number of samples, the new expressions generate a high value of measured P d and a low value of measured P f compared to the thresholds based on the CLT approach. For γ = −10 dB , P F f ( CDR−AA ) = 0.72 , while P CLT f ( CDR−CLT ) = 0.76 , which provides a gain up to 5% . As can be seen, in Fig. 7, for a very low SNR the false alarm probability is high and the detection probability is low due to the reduced number of samples. When increasing the SNR, the probabilities tend to improve until the measured values are close to those defined in project P d = 0.9 and P f = 0.1 , in the region close to γ ≈ −4 dB. By further increasing the SNR, the measured detection probability reaches the maximum value. The simulation results presented in Fig. 8 show the throughput of the secondary network, described in Sect. 1.2, as a function of γ for a constant number of samples. We used the same parameters as in [17], where T = 100 ms , τ S = 2.5 ms , γ S = 20 dB , P f = 0.1 , P d = 0.9 and PU's activity is set as P(H 0 ) = 0.8 and P(H 1 ) = 0.2 . For this simulation we used a constant number of samples N = 50 and we verified the novel constant threshold design as described in Sect. 2.3. It is possible to observe a gain in terms of throughput when the novel constant threshold is employed in comparison with the constant threshold based on CLT approach. For γ = −9 dB the throughput of SU network is R = 5.4853 bits/sec/Hz when we use ˆ CFAR−F , the throughput with ˆ CFAR−CLT based on CLT approach is R = 5.4798 bits/sec/Hz , which represents a gain up to 0.6% . The throughput gain is greater when the comparison is made between ˆ S or ˆ AA and ˆ CDR . For γ = −9 dB , a gain up to 12% is observed when the constant threshold ˆ CDR−S is used in comparison with ˆ CDR−CLT . Also a gain up to 7% is presented when the constant threshold ˆ CDR−AA is employed in comparison with ˆ CDR−CLT , for γ = −7 dB . These results show that in an unfavorable situation where the measured SNR is different from the project SNR γ , there is a moderate gain in terms of throughput for the cognitive radio network when we use the new approaches presented in this work. Some numerical values are compared in Table 1.

Conclusions
Exploring the approximations of the accumulated density functions of the central chisquare and non-central chi-square distributions, we arrive at new approximations of false alarm probability, detection probability and constant threshold for the energy detector. New expressions were also presented to find the minimum total error rate. The proposed approximations are closer to the original equations if compared to the approximation of the central limit theorem (CLT) already used in the literature. Unlike the CLT approach, which can be used for a large number of N, the presented approaches can also be used for a moderate number of samples. We show that the design with the new constant threshold expressions is more accurate in terms of measured false alarm and detection probabilities for different SNR values. The throughput of the cognitive network is enhanced when these novel expressions are implemented. The design based on the novel constant thresholds expressions supports greater noise variations, thus presenting greater stability in the detection of measured energy. The mathematical expressions obtained in this work can be applied in other fields of science besides spectrum sensing based on energy detection in cognitive radio. The equations presented cause a relatively impact on computational cost when energy detection is calculated; however, as the threshold is not calculated repeatedly the SU device does not experience others effects. As the equations presented are simple to implement, they can be used in all cognitive radio devices that already use the energy detector with an algorithm based on the CLT approach. The constant design threshold equations presented can be used as an alternative to the CLT approach for cases that require large amounts of samples ( γ << 0 dB ) and especially for cases that require a quantity moderate samples ( γ ≈ 0 dB ) as a network of sensors and communications in a finite length block regime. With the calculation of the minimization of the total error rate, very accurate results were obtained in the search for the detection threshold and the number of samples. Possibilities for future work are: the use of the approach presented in this work for environments with low SNR and the development of expressions for channels with fading based on the approaches used in this work. The continuous study of efficient techniques for the use of the spectrum opens space for new practical models of cognitive radio to be implemented in new generations of wireless communication systems.