## 5 Implementation of the Simulation Algorithm  
Algorithm 1 presented in this section was used to assess the accuracy of the ED SS process by employing the SLC method in the CRNs based on the MIMO-OFDM transmission. The algorithm was executed in Matlab software and it enabled the simulation of PU signal detection when impacted by different levels of NUs and DDTs. The flowchart presenting the workflow process of Algorithm 1 is shown in Figure 3.  
After defining the initial simulation parameters of Algorithm 1, in line 1, the generation of the PU signal and the reception of this signal over the \(R\) Rx antennas of SU were performed according to the principles of MIMO-OFDM transmission. As a result, the OFDM signal vector (_Mxr_) represented by Equation (2) was computed for each of the SU Rx branches. In lines 2-10 of Algorithm 1, the ED procedure employing the SLC technique was performed (Figure 3). The _Mxr_ signal detected at each of the \(R\) Rx branches of the SU, serves as the input signal of the ED process. To get reliable simulation results, several Monte-Carlo simulations (_mk_) were executed, and the efficiency of the ED method was assessed through the generation of ROC curves for the probability of false alarms in the range \([0,1]\) (Table 2). The impact of the AWGN with zero mean and variance \(\sigma_{w}^{2}(n)\) on ED process was modelled in line 3 of Algorithm 1. ```
1.Input: Number of Rx antenna: \(r=R\), Number of Tx antenna \(m=M\), Modulation type: m-PSK/m-QAM, Number of detection samples: \(N\), Tx power of PU: \(P_{Tx}\), Number of Mode-Carlo simulations: mk, OFDM symbol length: length_minmo_ofdm_data, transmitted signal by the PU: \(\textbf{M}\times\textbf{r}\). 2.FOR\(P_{fa}\) range [0,1] and FOR\(P_{fa}\) range



In line 4, a computation of the received signal impacted by AWGN was executed (Figure 3). The received signal _Y(n)_ (Figure 1) was divided into two different types. The first type of received signal (\(M\times r\_OFDM\_DDT\)) was detected using the DDT adaptation for the MIMO-OFDM communication system which is not impacted by the NU variations (\(\rho=1.00\), \(\rho^{\prime}>1.00\)). The second type of the MIMO-OFDM signal (\(M\times r\_OFDM\_NUIDDT\)) was detected by the DDT adjustments in a simulated environment which takes into consideration the received signal (\(M\times r\_OFDM\_DDT\)). The second type of the MIMO-OFDM signal (\(M\times



eration the impact of the NU variations (\(\rho>1.00\), \(\rho^{\prime}>1.00\)). By employing the SLC approach, the energy calculation of the signal detected over all \(R\) Rx antennas (_calculation_energy_-_DDT_, _calculation_energy_-_NUDDT_) was performed in line 5 of Algorithm 1 (Figure 3). In line 6 of Algorithm 1, the assignment of the test statistic was performed by combining the energies of the signals received from the \(R\) Rx branches in accordance with the Equation (3). This process resulted in the calculation of the two variants of test statistics (Figure 3). In the first variant, the calculation of the test statistics was executed based on the signals detected using DDT selection (_statistic_test_DDT_) in an environment lacking any impact of NU. In the second variant, the test statistic calculation was executed on the signals impacted by NU and for the ED performed with DDT selection (_statistic_test_NUDDT_). Based on the test statistics in line 7 of Algorithm 1, the two false alarm thresholds according to Equation (21) were calculated (Figure 3). The first threshold was computed without considering the NU variations (_threshold_DDT_), while the second calculated threshold included the effect of NU fluctuations on the ED performed by exploiting the DDT adjustments (_threshold_NUDDT_). Finally, in line 8 of Algorithm 1, the decision-making process was executed using the binary hypothesis testing according to Equation (4). Hypothesis \(H_{1}\) is confirmed if the received signal energy from all Rx antennas is greater than or equal to the threshold (_threshold_DDT_ or _threshold_NUDDT_).