1 Introduction

The enormous growth of wireless communications has created an ever increasing demand for frequency spectrum. Consequently, pressure is being mounted on the service providers to meet the end users’ requirement for higher bandwidth. The existing policies governing spectrum management are however, based on static spectrum allocation for a specific technology and service [1]. According to this static spectrum allocation policy, the systems are bound to operate within the assigned frequency band which often results in under-utilization and scarcity of the limited wireless spectrum [2, 3]. The wastage is owing to the fact that when there is no transmission, the assigned frequency bands remain idle. Several studies and measurements have been conducted around the world regarding spectrum utilization. The results point to the fact that spectrum utilization is concentrated only on certain portions of the allocated spectrum. Besides, a significant portion of the allocated spectrum remains unutilized while a considerably large portion is used occasionally [4]. A paradigm shift from static spectrum allocation currently being practiced to dynamic spectrum access is required [5]. Hence, the problems of under-utilization and spectrum scarcity have received a lot of attention in the global research community. Novel techniques for optimising spectrum usage are also being proposed to provide the urgently required panacea for addressing the problem of the unprecedented demand for spectrum access [6].

Mitola et. al. in [7] and [8] proposed the concept of cognitive radio (CR) as an effective solution to the problem of under-utilization and scarcity of the wireless spectrum. A CR is an intelligent radio device that can reason and adapt itself to the changes in activities within its radio frequency (RF) environment. It can autonomously detect which communication channels are in use and which are not, quickly migrate into the vacant channel while avoiding the occupied ones. Upon finding a vacant band to use in an opportunistic manner, it is required that a CR quickly vacates such band immediately the original assignee returns. The CR technology would enable wireless devices to efficiently utilize the spectrum in a dynamic manner. The users in the CR network can be categorized into two, namely; primary users (PUs) and secondary users (SUs). The PUs are the licensed users that have the right to use a specific portion of the spectrum, and the SUs are the unlicensed users that use the spectrum allocated to the PUs in an opportunistic manner, without causing harmful interference to the licensed users [5, 9, 10]. Spectrum sensing is the process through which CR devices are able to detect unused frequency bands in their RF neighbourhood. Thus, it is core to the successful implementation of the CR technology [9, 11].

Over the years, a lot of techniques have been studied and proposed for achieving spectrum sensing. Most popular methods include energy detection, matched filter and cyclostationary feature detection. All these techniques involve the detection of PU activities solely by utilising observations made by the SU. It is evident from literature that the energy detection technique, which is a non-coherent detection method is the most widely adopted. This is because it is very simple to implement compared to other techniques and does not require prior knowledge of the PU signal. However, it performs poorly in shadowing and fading environment especially when PU operates at low signal-to-noise ratio (SNR) [12,13,14]. The matched filter based detector compares the PU’s signal with a set of received signals in order to determine the presence or absence of the PU. Although, it is a very effective method for performing spectrum sensing, it requires that the SU has prior knowledge of the patterns in the PU’s signal [9]. Cyclostationary detectors take advantage of the certain statistical properties that are inherent in the PU’s signal which vary cyclically with time. These features also have a periodic statistics and spectral correlation that cannot be found in any interference signal or stationary noise. Thus, the method is effective for detecting the presence of the PU transmissions. As in the case of the matched filter, though, the scheme requires prior knowledge of the PU’s signal patterns at the SU. Besides, the method would fail if the PU alters any of these properties without notifying the SU. Furthermore, to mitigate the problem of shadowing, cooperative sensing has been proposed whereby multiple SUs are deployed at different geographical locations to perform local sensing of the PU signal [15]. The scheme exploits the spatial diversity of the multiple nodes by combining the local sensing information to make an overall decision about PU activities [16, 17].

It is noteworthy that CR devices need to be equipped with intelligence in order to be able to perform reasoning functionalities [5, 18]. To this end, various machine learning (ML) schemes have been proposed to effectively address the problem of spectrum sensing. For example, in [19], the support vector machine, K-nearest neighbours, K-means clustering and Gaussian mixture model methods are proposed while the unsupervised scheme based on the variational Bayesian learning technique is presented in [17]. A comprehensive review of parametric and non-parametric learning methods previously proposed is provided in [20]. Of late, the deep learning methods based signal classification techniques have been considered in [21,22,23,24] and [25].

1.1 Motivations and related works

The capability of parametric ML methods to effectively address the spectrum sensing problem is demonstrated in [19]. However, the performance of these proposed schemes would be severely degraded in a built up area due to the slowly fading channel occasioned by the mobility of SUs in the presence of scatterers [17, 26].

A consideration of existing literature shows that until now, there is dearth of study considering the deployment of these machine learning schemes in realistic scenarios involving the mobility of PU or SUs. In [27], the compromising effect of multipath fading and shadowing on the detection performance of spectrum sensing schemes was studied. In particular, overhead problem caused by the cooperation among SUs received attention and a reinforcement learning-based cooperative sensing scheme is proposed to address it. Also, in [28], the K-means clustering based learning method is proposed for enhancing the performance of cooperative spectrum sensing in generalized \(\kappa -\mu \) fading channels. Furthermore, concern about nodes placement in ML based cooperative sensing schemes was addressed in [29].

This study considers scenarios involving mobile SUs operating under flat fading channel condition and investigates the deployment of parametric ML methods for spectrum sensing under these conditions. To address the attendant sensing performance degradation, a real time channel tracking and decision boundary updating strategy is developed.

1.2 Contributions

In this paper, extending our work in [26], we consider a CR network of mobile SUs and investigate the K-means clustering techniqueFootnote 1 in a non-cooperative sensing scenario. The K-means clustering algorithm like other similar machine learning algorithms for pattern classification lends itself readily to decision plane tracking by updating the clusters centroids. However, different from [26] where the approximation of the time-varying channel was based on the first order Kalman filter combined with a first-order auto-regressive model, we propose a pilot based second-order (order-2) Kalman filter channel estimation technique for tracking the changes in the fading channel, and demonstrate the advantage within the context of spectrum sensing to improve the performance of the PU detection system. In addition, unlike the work in [26], no explicit cooperation is assumed between the PU and SUs. The second order Kalman filter yields a better approximation of the time varying channel [31, 32]. Furthermore, in comparison with its higher order counterparts, the order-2 Kalman filter scheme requires estimation of fewer parameters. The main contributions of this paper are as follows:

  • We have addressed the problem of spectrum sensing by mobile secondary devices under Rayleigh fading channel condition and modeled the task of monitoring the ensuing channel as a real time channel gain tracking problem. A pilot based second order Kalman filter algorithm has been developed for addressing it.

  • Using the knowledge of the Kalman channel gain estimates, we have proposed a completely unsupervised (no cooperation from PU) K-means clustering technique for adapting the centroids according to channel variations and for making classification decisions on the fly.

  • As a beneficial mechanism for estimating the location dependent noise plus interference power in the presence of secondary users mobility, we have proposed a model for estimating the noise plus interference power that can be used to adapt the centroid corresponding to the inactive PU.

We quantified the performance of the tracker in terms of mean square error and tracking accuracy whereas the performance of the enhanced spectrum sensing scheme is evaluated in terms of average detection probability, probability of false alarm and receiver operating characteristics.

The remainder of the paper is organized as follows. In Sect. 2 we provide the system model and assumptions. The process for the feature vectors realization, clustering algorithm and pilot based second order Kalman filter fading channel tracker are described in Sect. 3. Section 4 explains the quadratic polynomial regression model for the estimation of noise plus interference power. Numerical results are discussed in Sect. 5 followed by conclusion in Sect. 6.

2 System model and assumptions

We consider a CR network consisting of a PU transmitter (\(PU_{TX}\)), PU receivers (P-Rx) and a decentralized system of SUs. The SU system has multiple clusters, each consisting of a secondary base station (SBS) and J mobile SU receivers as illustrated in Fig. 1.

Fig. 1
figure 1

Description of a CR network consisting of a fixed PU transmitter, PU receivers and decentralized secondary network comprising a number of secondary base stations and mobile SUs

The PU transmitter is assumed to alternate between the ON (active) and OFF (inactive) states and its transmission power is fixed. The secondary networks share the same frequency channel with the primary system and the SUs in each cluster are assumed to be cooperating to jointly sense the PU’s activities. The essence of the joint sensing is to overcome the limitations caused by shadowing and to take advantage of the spatial diversity of the SUs. It is assumed that \(PU_{TX}\) periodically broadcasts to the PU receivers pilot signals which capture the channel state information of the paths traversed by the PU signals [30]. The attributes of the pilot signals are assumed to be known to the SUs so that the SUs can estimate the slowly fading channel between the \(PU_{TX}\) and the SUs during the training period. However, we assume there is no explicit cooperation between \(PU_{TX}\) and SU network, hence spectrum sensing is performed in an unsupervised manner.

Our proposed learning process is accomplished in two stages. During the first stage, the SUs within a particular cluster are assumed relatively stationary. They estimate the energy received from the transmitted PU signal and collectively report these to their serving SBS. The SBS uses the energy feature vectors to perform K-means clustering and to obtain centroids corresponding to ON and OFF status of \(PU_{TX}\). Since there are only two clusters, it is reasonable to assume that the cluster with its centre closer to the origin corresponds to OFF status while the other cluster corresponds to the ON status. There is no need for the labels of PU transmission and hence, there is no explicit cooperation between PU and SU networks.

In the second stage, it is assumed that SUs make random walks and the channels between the PU and the SUs are treated as time-variant as the SUs move around in the presence of scatterers within the coverage area of the PU. Due to this mobility, as the underlying channel varies, the energy that is supposed to be received during the PU active status varies. Hence, the cluster centroid corresponding to ON status of \(PU_{TX}\) is updated continuously with the aid of the proposed Kalman filter channel tracking algorithm, that is, we estimate the predicted channel coefficients of each moving SUs and compute the estimate of the received energy and update the K-means cluster.

If the instantaneous PU signal received by the \(j\in J\) SU is represented by \(x_{j}(n)\), the goal of the spectrum sensing is to decide between two hypotheses, namely; the PU is absent which corresponds to the hypothesis \(H_{0}\), and the PU is present which corresponds to the hypothesis \( H_{1} \). This can be expressed as

$$\begin{aligned} x_{j}(n)={\left\{ \begin{array}{ll} \eta _{j}(n), , ~~~~H_{0}\\ s(n) \gamma _{j}(n) + \eta _{j}(n), , ~~~~H_{1} \end{array}\right. } \end{aligned}$$
(1)

where s(n) is the signal transmitted by the PU, assumed to be an independent and identically distributed (i.i.d) process with zero mean and variance, \({\mathbb {E}}[|s(n)|^{2}] = \sigma _{s}^{2}\). The parameter \(\gamma _{j}(n)\) is the non-frequency-selective channel coefficient between the PU and the \(j^{th}\) SU which is assumed to be Rayleigh distributed. However, we estimate this parameter at every block interval using pilot signals. Hence, for the purpose of channel estimation, at every block interval, \(\gamma _{j}\) is treated as deterministic, but it is assumed to vary according to a Rayleigh distribution between the blocks. Finally, \(\eta _{j}(n)\) is an i.i.d circularly symmetric complex zero-mean additive white Gaussian noise (AWGN) with variance, \({\mathbb {E}}[|\eta _{j}(n)|^{2}] = \sigma _{\eta }^{2}\) and \({\mathbb {E}}[.]\) denotes the expectation operator.

3 Features realization, clustering algorithm and fading channel tracker

3.1 Energy vectors realization for SUs

During the learning interval, it is assumed that the PU alternates between \(H_{0}\) and \(H_{1}\). So, the normalized energy estimated at \(j^{th}\) SU node is given as

$$\begin{aligned} \phi _{j}=\frac{1}{N_{s}}\sum _{n=1}^{Ns}|x_{j}(n)|^{2} \end{aligned}$$
(2)

where \( N_{s} \) is the total number of samples taken during the observation window.

The energy feature, \(\phi _{j}\) is a random variable whose probability density function (PDF) follows a central Chi-square distribution under \(H_{0}\) and a non-central Chi-square distribution conditional on the channel gain under \(H_{1}\), both with \(2N_{s}\) degrees of freedom [33,34,35]. Furthermore, when \(N_{s}\) is large enough (say, \(N_{s} \simeq 250\)) [35], under \(H_{0}\) this PDF can be approximated as Gaussian via the central limit theorem with mean, \(\mu _{0}\) = \(\sigma _{\eta }^{2}\) and variance, \(\sigma _{0}^{2}\) = \(\frac{1}{N_{s}}[{\mathbb {E}}|\eta (n)|^{4}-\sigma _{\eta }^{4}]\) [17]. Similarly, the distribution of \(\phi _{j}\) under \(H_{1}\) and with large \(N_{s}\) can be approximated as Gaussian with mean, \(\mu _{1}\) = \(|\gamma _{j}|^{2}\sigma _{s}^{2} + \sigma _{\eta }^{2}\) and variance, \(\sigma _{1}^{2}\) = \(\frac{1}{N_{s}}[|\gamma _{j}|^{4}{\mathbb {E}}|s(n)|^{4} + {\mathbb {E}}|\eta (n)|^{4}-(|\gamma _{j}|^{2}\sigma _{s}^{2} - \sigma _{\eta }^{2})^{2}]\).

When Kalman gain is used for estimating energy, we estimate the energy as

$$\begin{aligned} \phi _{j} = |\gamma _{j}|^{2} P_{Tu} + \sigma _{\eta }^{2} , \end{aligned}$$
(3)

where \(P_{Tu}\) is the PU transmission power. For constructing energy clusters, Z energy samples, \(\phi _{j}\) are collected and reported to the serving SBS by each of the cooperating SUs. The set of energy vectors obtained at the SBS from all SUs during the clustering period is represented by \(S = \{\varvec{\phi }_{1}, ..., \varvec{\phi }_{Z}\} \) where \(\varvec{\phi }_{z}\in \mathfrak {R}^{M}\), \(z\in Z\) and \(M\le J\) is the corresponding number of collaborating SUs. We employ K-means clustering that clusters the set S of energy vectors \(\varvec{\phi }_{z}\) to two classes \( H_{1} \) and \( H_{0} \). The centroid that is closer to the origin is deemed to be the centroid for \(H_{0}\) and the other one corresponds to \(H_{1}\). During deployment, the class to which a test energy vector belongs can be determined by comparing the energy vector to the centroids of the two clusters and a decision can be made based on the minimum Euclidean distance [20].

3.2 The K-means clustering algorithm

The K-means clustering algorithm partitions a set of data into K disjoint clusters. In our case, K is 2 and the algorithm aims to minimize the measure between the centroids of the clusters and the given set of data by iteratively assigning the data into the cluster with the closest centroid. The end result of the K-means algorithm is a set of clusters that are tightly packed and well-separated for every group.

Let \(S = \{\varvec{\phi }_{z}\}_{z=1}^{Z} \) \(\in \) \(\{H_{1}, H_{0}\}\) be the set of energy feature vectors obtained using (2). Also, let \(C_{k}\) denote the set of training energy vectors that belong to cluster k which has a centroid \(\varvec{\theta }_{k}\) defined as the mean of all the training energy vector in \(C_{k}\)  :  \(S = \{C_{k}\}_{k=1}^{K}\). According to [36], the K-means algorithm aims to obtain K clusters which minimize the within-cluster sum of squares as

$$\begin{aligned}&\underset{S}{{minimize}}~~~~~~~~ \sum _{k=1}^{K}\sum _{\varvec{\phi }_{z}\in C_{k}}^{}\Vert \varvec{\phi }_{z} - \varvec{\theta }_{k}\Vert ^{2} \nonumber \\&\text {subject}~to~~~\varvec{\theta }_{k} = \frac{1}{card~C_{k}}\sum _{\varvec{\phi }_{z}\in C_{k}} \varvec{\phi }_{z},\nonumber \\&~~~~~~~~~~~~~~~~ S = \bigcup ^{K}_{k=1} C_{k}. \end{aligned}$$
(4)

where card implies the cardinality function. The clustering algorithm in (4) is employed at the SBS to derive the required clusters’ centroids. A generalized pseudo-code for implementing (4) is provided in Algorithm 1. The cluster centroid corresponding to \(H_{0}\) can be identified as

$$\begin{aligned} \varvec{\theta }^{*}_{k\mid k \mapsto H_{0}} = {\text {*}}{argmin}_{k \in K}~~\Vert \varvec{\theta }_{0} - \varvec{\theta }^{*}_{k}\Vert \end{aligned}$$
(5)

where \(\varvec{\theta }_{0}\) is a zero vector, \(\vec {0}\in \mathfrak {R}^{M}\) representing the origin of the clusters’ plane.

It should be noted however, that when mobility of SUs is considered, the centroids obtained under \(H_{1}\) must be continuously updated for reliable detection of PU’s activities. In the Sub-Sect. 3.3, we describe a Kalman filter based scheme for tracking the gradual changes in PU-SU channel which would facilitate “on the fly” updating of the centroid-based decision plane for our spectrum sensing system.

figure e

3.3 Fading channel model and estimation

We consider the mobility of SUs in heavily built-up areas resulting in the presence of scatterers in their RF operating environment. Our aim is to estimate the slowly varying channel gain between the PU transmitter and SUs which can be modeled as flat fading Rayleigh channel [31, 37] using the second order Kalman filter tracker. Let the discrete-time observation at the mobile SU terminal be given by

$$\begin{aligned} y (n)=\beta (n)\gamma (n)+\eta (n) \end{aligned}$$
(6)

where n is the symbol time index, \( \beta (n) \) is a known modulated pilot signal periodically broadcasted by \(PU_{TX}\), \( \gamma (n) \) is the complex Gaussian channel coefficient whose variance is \(\sigma ^{2}_{\gamma }\), \(\eta (n)\) is the zero mean AWGN at the receiver with variance \(\sigma ^{2}_{\eta }\). The noisy measurement of the channel gain from the pilot at the SU is \({\hat{\gamma }}\).

Referring to (1) and ignoring the user index j, the magnitude of the instantaneous channel gain, \(\alpha \) = \(|\gamma (n)|\) is a Rayleigh distributed random variable. The autocorrelation of the fading channel coefficient \(R_{\alpha }[\mu ]\) is defined for lag \(\mu \) as

$$\begin{aligned} R_{\alpha }[\mu ] = {\mathbb {E}}[\gamma (n)\gamma ^{*}(n-\mu )] = \sigma ^{2}_{\alpha }J_{0}(2 \pi f_{d} T_{s} \mu ) \end{aligned}$$
(7)

where \( J_{0}(\cdot ) \) is the zeroth order Bessel function of the first kind, \(\sigma ^{2}_{\alpha }\) = \(\sigma ^{2}_{\gamma }\), \(f_{d}\) is the Doppler frequency and \(T_{s}\) is the symbol interval. For Kalman filter based channel estimation, in addition to the noisy observation \({\hat{\gamma }}\), an approximate state-space representation of the evolution of the channel gain is required. For the first order Kalman tracker approach described in [26], the state-space model is described by

$$\begin{aligned} \alpha ^{AR_{1}}(n)=\delta _{1}\alpha ^{AR_{1}}(n-1) + \xi (n) \end{aligned}$$
(8)

where \(0<\delta _{1}<1\) and \(\xi (n)\) is the complex AWGN with variance, \(\sigma ^{2}_{\xi }\) = \((1-\delta _{1}^{2})\sigma ^{2}_{\alpha }\). However, in the current work, we propose to use the second order autoregressive model (\(AR_{2}\)) being a more suitable approximation to the fading channel in the estimation problem being considered [37, 40].

The \(AR_{2}\) model with Gaussian assumption which approximates the flat fading Rayleigh channel can be expressed as a difference equation of the form

$$\begin{aligned} \alpha ^{AR_{2}}(n)=\delta _{1}\cdot \alpha ^{AR_{2}}(n-1) + \delta _{2}\cdot \alpha ^{AR_{2}}(n-2) + \xi (n) \end{aligned}$$
(9)

where the model coefficients, \(\delta _{1}\) and \(\delta _{2}\) are the first and second order autoregressive coefficients respectively, whose values are obtained by imposing the correlation matching criterion as [37]

$$\begin{aligned} \delta _{1} = \dfrac{R_{\alpha }[1]}{R_{\alpha }[0]}=\dfrac{\sigma _{\alpha }^{2}J_{0}(2 \pi f_{d}T_{s}\cdot 1)}{\sigma _{\alpha }^{2}J_{0}(0)} \end{aligned}$$
(10)

which may be further re-expressed as

$$\begin{aligned} \delta _{1} = J_{0}(2 \pi f_{d}T_{s}) \end{aligned}$$
(11)

and

$$\begin{aligned} \delta _{2} = \dfrac{R_{\alpha }[2]}{R_{\alpha }[1]} = \dfrac{J_{0}(2 \pi f_{d}T_{s}\cdot 2)}{J_{0}(2 \pi f_{d}T_{s})}. \end{aligned}$$
(12)

The remaining parameter \(\xi (n)\) in (9) is the AWGN with variance, \( \sigma _{\xi }^{2} \) and n remains the symbol index.

According to the Kalman filter framework, the tracking equations can be separated into two parts. These are the prediction equations that implement the prediction stage by means of appropriately chosen models and the correction equations for correcting the errors and inaccuracies arising in the estimation process with the aid of the measurement received [43].

The prediction stage: In general, the prediction equation that models a system’s process evolution takes the form of the first order linear difference equation expressed as [26]

$$\begin{aligned} \alpha (n) = A\alpha (n-1) + Bu(n) + w(n-1) \end{aligned}$$
(13)

where the associated parameters can be initialized with A = \(\delta _{1}\), B = 0 and u(n) = 0 while \(w(n-1)\) is the process white noise. The measurement equation for correcting errors in the prediction is also described by an expression of the form

$$\begin{aligned} z(n) = H\alpha (n) + v(n) \end{aligned}$$
(14)

where H is the measurement model which maps the true state space into the observed space and v(n) is a random variable representing the measurement noise. In this work, we adopted (6) as a form of (14) to derive the required multiple sequential measurements while (9) was used as the prediction equation that models the dynamics of the slowly fading channel. Furthermore, the state prediction error covariance is accounted for by the projection equation

$$\begin{aligned} P(n) = AP(n-1)A^{T} + Q \end{aligned}$$
(15)

where P is the covariance of the state prediction error and the matrix A is defined by

$$\begin{aligned} A = \begin{bmatrix} 1 &{} 0\\ \delta _{1} &{} \delta _{2} \end{bmatrix} \end{aligned}$$
(16)

while \((.)^{T}\) denotes the transpose operation. Also, the parameter Q in (15) is the prediction process noise covariance given by

$$\begin{aligned} Q = \begin{bmatrix} (1-\delta ^{2}_{1})\sigma ^{2}_{\alpha } &{} (1-\delta _{2}\delta _{1})\sigma ^{2}_{\alpha }\\ (1-\delta _{2}\delta _{1})\sigma _{\alpha }^{2} &{} (1-\delta ^{2}_{2})\sigma _{\alpha }^{2} \end{bmatrix}. \end{aligned}$$
(17)

The correction stage:  To correct the errors associated with the prediction of the channel gain process evolution using the measurements received from the PU’s pilot, we first compute the Kalman gain as

$$\begin{aligned} K(n) = \frac{P(n)H^{T}}{HP(n)H^{T} + R} \end{aligned}$$
(18)

where the parameter R represents the measurement noise covariance whose value depends on the peculiarity of the PU-SU operating environment. For the second order approximation to Kalman filter, the matrix H is defined as [41]

$$\begin{aligned} H = \begin{bmatrix} 0&1 \end{bmatrix} . \end{aligned}$$
(19)

The optimal estimate of the PU-SU channel gain is then obtained by combining the Kalman gain in (18) with the measurement and prediction Eqs. (6) and (9) yielding the joint a posteriori estimate as

$$\begin{aligned} \begin{bmatrix} {\hat{\alpha }}^{AR_{1}}(n)\\ {\hat{\alpha }}^{AR_{2}}(n) \end{bmatrix}=\begin{bmatrix} \alpha ^{AR_{1}}(n)\\ \alpha ^{AR_{2}}(n) \end{bmatrix} + K(n)\left( \alpha (n) - H \begin{bmatrix} \alpha ^{AR_{1}}(n)\\ \alpha ^{AR_{2}}(n) \end{bmatrix}\right) \end{aligned}$$
(20)

and

$$\begin{aligned} {\hat{P}}(n) = \big (I - HK(n)\big )P(n)~. \end{aligned}$$
(21)

From (20), the desired estimate of the magnitude of the channel gain is extracted as

$$\begin{aligned} {\hat{\alpha }}^{AR_{2}}(n) = H\begin{bmatrix} {\hat{\alpha }}^{AR_{1}}(n)\\ {\hat{\alpha }}^{AR_{2}}(n) \end{bmatrix}. \end{aligned}$$
(22)

It should be noted that \(\alpha ^{AR_{1}}(n)\) and \(\alpha ^{AR_{2}}(n)\) in (20) are the initial rough estimates obtained from the prediction process before correction is done by using the measurement update and I in (21) is the identity matrix. After each cycle of projection in time and measurement update, the process is repeated such that the a posteriori estimates become the initial values for the next cycle. Once the optimal estimate of the PU-SU channel gain has been obtained, the corresponding energy samples will be derived using (3).

4 Quadratic polynomial regression algorithm for energy prediction

As highlighted in Sect. 2, using the Kalman flter channel estimate, the energy at each SU receiver can be estimated using (3). In order to apply this, we need to have a reliable estimate of the noise power at the receiver, which can be estimated in the absence of any PU transmission. The noise power may include the co-channel interference due to any other transmitters in different cells. In the presence of mobility, the power of noise plus co-channel interference may vary due to various spatial locations. Estimation of this noise power would become non-trivial if the PU is also active. Hence, we propose a method of estimating the noise power during mobility of users and the PU transmission as below.

Let \(\phi _{j,\omega }\) and \(\alpha _{j,\omega }\) = \(|\gamma _{j}|\) denote the estimate of the energy and channel gain at various instants \(\omega \) for SU receiver j. Hence for each SU j, we may relate the energy and channel gain as follows:

$$\begin{aligned} {\hat{\phi }}_{j,\omega } = c_{0,j}~+~ c_{2,j}{\hat{\alpha }}_{j,\omega }^{2}~+~\varepsilon _{j,\omega } \end{aligned}$$
(23)

where \(c_{0,j}\) is the noise plus interference power and \(c_{2,j}\) is the PU transmission power, both are the model parameters we seek to determine, \(\varepsilon _{j,\omega }\) is an unobserved random error with zero mean conditioned on variable \({\hat{\alpha }}_{j,\omega }\).

Considering each SU receiver has N number of energy-channel estimate samples corresponding to various time instants, the regression model in (23) can be expressed in terms of a response energy vector \(\varvec{\phi }\), a design matrix \({\varvec{A}}\) of estimated channel gain, a model parameter vector \(\varvec{c}\), and random errors vector \(\varvec{\varepsilon }\) as

$$\begin{aligned} \begin{bmatrix} {\hat{\phi }}_{j,1} \\ {\hat{\phi }}_{j,2} \\ \vdots \\ {\hat{\phi }}_{j,N} \\ \end{bmatrix} = \begin{bmatrix} 1 &{} {\hat{\alpha }}_{j,1}^{2} \\ 1 &{} {\hat{\alpha }}_{j,2}^{2} \\ \vdots &{} \vdots \\ 1 &{} {\hat{\alpha }}_{j,N}^{2} \end{bmatrix} \begin{bmatrix} c_{0,j} \\ c_{2,j} \\ \end{bmatrix} + \begin{bmatrix} \varepsilon _{j,1} \\ \varepsilon _{j,2} \\ \vdots \\ \varepsilon _{j,N} \\ \end{bmatrix} , \end{aligned}$$
(24)

which may be written compactly as

$$\begin{aligned} \varvec{\phi }_{j} = {\varvec{A}}\varvec{c}_{j} + \varvec{\varepsilon }_{j}. \end{aligned}$$
(25)

Using the ordinary least square estimation method [42], the vector of estimated polynomial regression coefficients is then obtained as

$$\begin{aligned} \varvec{{\hat{c}}}_{j} = {\big ({\varvec{A}}^{T}{\varvec{A}})}^{-1}{\varvec{A}}^{T}\varvec{\phi }_{j}~. \end{aligned}$$
(26)

Hence, the first element of \(c_{j}\) would provide the estimate of the noise plus interference power at the \(j^{th}\) SU receiver. Once the estimates of the energy from all participating SUs are obtained from the estimates of the channel gains and the noise power as in Eq. (3), the centroid for \(H_{1}\) cluster is updated as

$$\begin{aligned} \varvec{\theta }^{*}_{H_{1},w} = \beta \varvec{\theta }^{*}_{H_{1},w-1} + (1 - \beta ) \hat{\varvec{\phi }_{w}} \end{aligned}$$
(27)

where \(\beta \) is an adaptation parameter, \(0<\beta <1\). In Algorithm 2, the proposed second-order Kalman filter based channel estimation technique applied within the context of spectrum sensing problem is presented.

figure f

5 Simulation results and discussion

5.1 Parameters for the study

PU transmit power = 1W.

Duration of the fading channel gains tracked = 30000 Symbols.

Number of collaborating SU = 3.

Variance of the fading channel gain = 1.

Centroid adaptation parameter, \(\beta \) = 0.9

Order-1 autoregressive coefficient, \(\delta _{1}=0.2203 \).

Order-2 autoregressive coefficient, \(\delta _{2}=0.7149 \).

Process noise covariance for first-order Kalman filter, \( Q_{1}=(1-\delta _{1}^{2})=0.9515 \).

Process noise covariance for second-order Kalman filter, \( Q_{2}=0.2203 \).

5.2 Numerical results

For the Jake’s fading model, the velocity of each SU is set to 6 km/hr. We generated 30,000 symbols received at the central frequency, \( f_{c}\) of 2 GHz. Without loss of generality, we assume that the average power \(P_{avg.}\) of the fading process is unity, but the proposed method would be applicable to any other value of \(P_{avg}\). The duration of the PU symbol is set to 33.33 \(\mu \)s transmitted at the central frequency, \(f_{c}\). The SUs are assumed to be equipped with omnidirectional antennas while the scatterers are assumed to cause the signals to be received at uniformly distributed angles of arrival. Furthermore, the PU is considered to alternate between the active and inactive states so that the number of clusters, K is set to 2. For the study, each energy sample is computed using the channel estimate which was based on varied pilot length, L. We first considered the case where the PU is cooperating with the SUs and assumed that the pilot is available all the time, only to compare the performance of the order-1 Kalman and order-2 filters. However, a more realistic case where there is no PU cooperation is considered for the rest of the simulations.

Fig. 2
figure 2

Mean square error performance comparison between first and second order Kalman filter under different SNR considerations

Fig. 3
figure 3

Tracking accuracy of the second order Kalman filter tracker under time-varying channel gain tracked at SNR = − 10 dB and 10 dB, PU’s duty cycle at 50 \(\%\) and 100 \(\%\), and pilot length, L = 10 symbols

In Fig. 2, by 1000 Monte Carlo repetitions, we show the comparison between the estimation capabilities of the first order and the second order Kalman filter in terms of the mean square error (MSE) estimate of the fading over a range of PU’s operating SNR from − 8 dB to 30 dB and length of pilot symbols for channel estimation, L, equals 10. The PU was considered to be operating at 100\(\%\). It can be seen that for the proposed order-2 Kalman tracker, the MSE dropped appreciably from 0.164 to 1.08\(\times 10^{-4}\) as SNR is increased from − 8 dB to 30 dB while a drop from 0.382 to 1.8\(\times 10^{-4}\) is observed for the order-1 tracker.

Similarly, a shift from the order-1 to order-2 filter indicates about 57.89\(\%\) reduction in estimation error at SNR of -8 dB, that is, the MSE dropped from 0.382 to 0.164 whereas at the SNR of 30 dB, a decrease of about 40.13 \(\%\) is seen. These results clearly indicate that the proposed order-2 tracker is a better estimator compared to the order-1 tracker at all cases of SNR considered.

The tracking capability of the second order Kalman filter is presented in Fig. 3. Here, the tracker’s performance is evaluated in terms of tracking accuracy over the duration of 6000 symbols at the PU’s operating SNRs of − 10 dB and 10 dB. The cases considered are both when the PU is operating at 100 percent duty cycle (the PU is active with pilot transmissions all the time) and when operating at 50 percent duty cycle (PU is active only 50\(\%\) of the time alternating between ON and OFF) and when there is no cooperation with the secondary network. As observed throughout the observation window, the order-2 filter shows a good tracking performance and closely matches up with the true channel gain in both scenarios.

Fig. 4
figure 4

Comparison between Order-2 and Order-1 Kalman filter channel tracking based spectrum sensing schemes showing average detection probability versus SNR at zero false alarm probability and PU’s 100\(\%\) duty cycle, Number of SUs, M = 3, and pilot length, L = 10 symbols

Fig. 5
figure 5

Comparison between Order-2 and Order-1 Kalman filter channel tracking based spectrum sensing schemes showing average detection probability versus SNR at PU’s 50\(\%\) duty cycle, Number of SUs, M = 3, and pilot length, L = 10 symbols

In Fig. 4, we show the comparison between the order-1 and order-2 filter based scheme in terms of their performance for detecting the presence of the PU under the assumption that there is a cooperation between the PU and SUs and the pilot is available all the time. It can be seen here that the order-2 based sensing scheme performs better that the order-1 scheme especially as the SNR is degraded. For example, although both schemes maintained zero average false alarm probability (\(Pfa_{ave}\)) throughout the SNR range considered, an average detection probability (\(Pd_{ave}\)) performance gain of about 4 \(\%\) is offered by the order-2 scheme as the SNR is reduced from 16 dB to − 4 dB. We opine that the improvement offered by the order-2 Kalman filter based scheme over the order-1 counterpart is likely as a result of its capability to capture the dynamics of the varying channel evolution better and the consequent decrease in the channel estimation errors as previously highlighted.

In Figs. 5 and 6, we focus on the performance of the two filters in a more realistic scenario where the PU and the SU networks do not cooperate and the PU operates at 50 \(\%\) duty cycle. For the study, we set the pilot length, L to 10 and quantified the performance of both schemes in terms of \(Pd_{ave}\) and \(Pfa_{ave}\). In Fig. 5, about 3\(\%\) detection performance improvement is seen to be offered by the order-2 scheme at the SNR of − 4 dB where the \(Pd_{ave}\) rises from about 0.71 to 0.74 with the use of order-2 based sensing scheme instead of the order-1 based scheme. Similar improvement in \(Pd_{ave}\) can be observed within the SNR range of − 4 dB to 6 dB. Similarly, the \(Pfa_{ave}\) is reduced from 0.164 to 0.149 (about 9\(\%\)) at − 4 dB in favor of the order-2 based scheme over the order-1 scheme. This improvement in \(Pfa_{ave}\) performance can also be observed throughout the SNR range of − 4 dB to 6 dB.

Fig. 6
figure 6

Comparison between Order-2 and Order-1 Kalman filter channel tracking based spectrum sensing schemes showing average false alarm probability versus SNR at PU’s 50\(\%\) duty cycle, Number of SUs, M = 3, and pilot length, L = 10 symbols

Fig. 7
figure 7

Comparison between Order-2 Kalman filter channel tracking based and NTM sensing schemes showing average detection and false alarm probabilities versus SNR at PU’s 50\(\%\) duty cycle, Number of SUs, M = 3, and pilot length, L = 10 symbols

We show the performance of the proposed order-2 filter based channel tracking spectrum sensing scheme under mobile SUs scenario and compare with the performance of the scheme where channel tracking is not used, that is, non-tracking mode (NTM) in Fig. 7. The PU’s operation is maintained at 50\(\%\) duty cycle and L is kept at 10. As seen, the channel tracking based scheme exhibits superior performance in terms of \(Pd_{ave}\) compared to the NTM system throughout the entire SNR range considered. It is especially noteworthy that as the SNR is improved from − 10 dB to 20 dB, while the proposed channel tracking based scheme provides improvement in both \(Pd_{ave}\) and \(Pfa_{ave}\), there is no noticeable performance gain in the NTM scheme. Furthermore, due to fading, the NTM scheme is characterized by significant missed detection. This indicates that the NTM scheme fails to cater to the challenges of PU detection in spectrum sensing for cognitive radio system when the SUs are mobile within the network and the PU-SU channel experiences aging/fading. It should be noted that for the NTM scheme, the centroids remain the same throughout the testing period, however, the true channel has been varied according to the Jakes fading model. Hence, the \(Pd_{ave}\) and \(Pfa_{ave}\) performance would be influenced by the initial channel values of the fading profile.

In Fig. 8, we study the effect of the variation in the duty cycle of the PU on the performance of the proposed channel tracking sensing scheme and the NTM scheme over the SNR range of − 10dB to 20dB. It can be observed that as the duty cycle is increased from 25\(\%\) to 75\(\%\), the performance of the proposed order-2 scheme improves as measured by \(Pd_{ave}\) and \(Pfa_{ave}\). For example, at the SNR of − 10dB, the proposed scheme offers an increase in \(Pd_{ave}\) from 0.54 to 0.75 (about 39\(\%\) gain) while the \(Pfa_{ave}\) is reduced by about 66 \(\%\) from 0.41 to 0.14. An overall improvement in the performance of the channel tracking based scheme can also be observed as the SNR is improved from − 10dB to 20dB. On the other hand, although the NTM scheme maintains zero \(Pfa_{ave}\) throughout the range of SNR considered, its capability to detect the presence of the PU is reduced as the duty cycle of the PU is increased. The reduction in the NTM’s capability for PU’s detection is noticed across all SNR where \(Pd_{ave}\) is maintained at approximately 0.26 and 0.75 for 75\(\%\) to 25\(\%\) duty cycle respectively.

Fig. 9 shows the effect of varying the pilot length used for channel estimation on the performance of the proposed order-2 filter tracking based sensing scheme. It can be observed that as the pilot length is increased from 10 symbols to 30 symbols at 50\(\%\) duty cycle operation of the PU, the system’s performance is improved. For example, at the SNR of − 10 dB, \(Pd_{ave}\) is raised from 0.62 to 0.72 (about 16\(\%\) gain) while the \(Pfa_{ave}\) is reduced from 0.29 to 0.17 (about 41\(\%\) reduction). It is noteworthy that at the SNR of 0 dB, the proposed scheme achieves zero \(Pfa_{ave}\) and 0.96 \(Pd_{ave}\) when the number of symbols in the pilot length is 30 indicating the capability of the proposed scheme to meet the performance requirement of CRs in terms of detection accuracy.

Fig. 8
figure 8

Comparison between PU-SU cooperation and non-cooperation modes showing the average probabilities of detection and false alarm versus SNR, Number of SUs, M = 3, and pilot length, L = 10 symbols

Fig. 9
figure 9

Comparison Order-2 Kalman filter scheme showing the average probabilities of detection and false alarm versus SNR, Number of SUs, M = 3 at pilot length, L = 10, 20 and 30 symbols

The receiver operating characteristics performance of the proposed second order Kalman filter channel gain estimation based sensing scheme is shown in Fig. 10. We considered 10 symbols and 20 symbols for the pilot length while the PU operating SNR of − 5 dB, 0 dB and 5 dB were used for the investigation. It can be seen that the system’s performance is enhanced both when the SNR improves and when the pilot length is increased. For example, at 5 dB, given that the operational duty cycle of the PU is kept at 50\(\%\), a \(Pd_{ave}\) of 0.94 is achieved at the \(Pfa_{ave}\) of 0.1. Furthermore, given the same PU operational duty cycle and \(Pfa_{ave}\) of 0.1, an increase in \(Pd_{ave}\) from 0.53 to 0.63, 0.78 to 0.9, and 0.94 to 0.98 are obtained at the SNR of − 5 dB, 0 dB and 5 dB respectively as symbol size of the pilot used for the channel estimation is raised from 10 symbols to 20 symbols. These results further lend credence to the robustness of the proposed second order Kalman filter channel estimation method for spectrum sensing in CR networks of mobile SUs.

Fig. 10
figure 10

Performance of Order-2 Kalman Filter based scheme showing the receiver operating characteristics at SNR = − 5 dB, 0 dB and 5 dB, Number of SUs, M = 3, and pilot length, L = 10 and 20 symbols

Finally, to conclude our investigations, we consider the implementation complexity of the proposed Kalman filter channel estimation based spectrum sensing scheme. The evaluation was done on an Intel core \(i5-5200U\) dual processors with CPU clocking speed of 2.20GHz and using MATLAB software version R2016b. Our comparison is based on the computation of average learning and prediction durations for implementing the first and second order channel gain trackers. For the same parameters as used in the previous simulations, the computation time averaged over 10,000 Monte Carlo runs for the first and he second order trackers are 18.97 \(\mu \)s and 22.64 \(\mu \)s respectively. As expected, the second order channel gain tracker has more computational complexity as compared to the first order channel gain tracker, however, this is compensated by the improvement in sensing performance as seen in the previous simulations.

6 Conclusion

In this paper, we studied the problem of spectrum sensing in cognitive radio networks of mobile secondary users. In particular, we considered the performance degradation that occurs when mobile secondary users are cooperatively sensing primary user’s activities under flat fading channel conditions in the presence of scatterers. We presented a second order Kalman filter technique for real time estimation of the slowly fading channel gain between the primary user and secondary users. The estimated channel gain was then used to update the centroids of the K-means clustering based spectrum sensing scheme ”on the fly”. The performance of the proposed channel estimation technique was evaluated using mean square error estimation and tracking accuracy metrics while the performance of the ensuing spectrum sensing algorithm was quantified in terms of probability of detection, probability of false alarm and receiver operating characteristics. Simulation results show that the proposed techniques offer significant advantage for spectrum sensing in cognitive radio networks of mobile secondary users in comparison with previously proposed alternatives.