# User-BS Selection Strategy Optimization with RSSI-Based Reliability in 5G Wireless Networks
## 5 Wireless BS Selection-Strategy Optimization Based on User Trajectory
### Density Estimation  
Kernel density estimation is a nonparametric estimation method that does not use prior knowledge about the data distribution and does not attach any assumptions to the data distribution. It is a method to study the characteristics of the data distribution from the data sample itself, which is consistent with our unknown user distribution situation. The so-called kernel density estimation is to use a smooth peak function, which is called a 'kernel', to fit the observed data points, thereby simulating the true probability distribution curve. Assuming that \(x_{1},x_{2},\ldots,x_{n}\) are the \(n\) sample points of independent and identically distributed \(F\), whose probability density function is \(f\), the kernel density can be estimated as follows:  
\[f_{h}(x)=\frac{1}{n}\sum_{i=1}^{n}K_{h}(x-x_{i})=\frac{1}{nh}\sum_{i=1}^{n}K( \frac{x-x_{i}}{h}), \tag{34}\]  
where \(K(\cdot)\) is the kernel function (non-negative, integral is 1, conforms to the nature of probability density, and the mean is 0). There are many kinds of kernel functions, for example, uniform, triangular, biweight, triweight, Epanechnikov, and normal. Commonly used kernel functions include the Gaussian and Epanechnikov kernels [37]:  
\[K(x)=\frac{1}{\sqrt{2\pi}}\exp{(-\frac{x^{2}}{2})}\;(\text{Gaussian}\;\;\; \text{Kernel}), \tag{35}\]  
\[K(x)=\frac{3}{4}(1-x^{2})I(|x|\leq 1)\;(\text{Epanechnikov}\;\;\text{Kernel}). \tag{36}\]  
We used a 3-dimensional kernel density estimation method to estimate the user density at the input location coordinate point, and selected the optimal Epanechnikov kernel in the sense of mean square error to estimate. At the same time, we also added the automatic calculation of bandwidth \(h\) in Formula (34) according to the Scott principle of the d-dimensional space:  
\[h=\sqrt{5}\cdot n^{\frac{1}{d+4}}, \tag{37}\]  
where \(N\) represents the number of data. We consider both space data and time data; first, the space-time kernel density function is estimated and then integrated into the time dimension. However, because it is impossible to accurately calculate the space-time nuclear density function, we could only use numerical methods to calculate the space-time nuclear density of the input position coordinates at these time nodes according to a certain time interval, which represents density in this time interval multiplied by the time interval and accumulated as the integration process. The specific algorithm pseudocode is shown as Algorithm 2. ```
0:\(points\): target location; \(data_{space}\): spatial data; \(data_{ti}\): time data; \(d\): data dimension;
0:\(Den\): estimated density;
1:initialize: Set \(Den=0\);
2: Convert latitudinal and longitudinal data (\(points\) and \(data_{space}\)) into coordinate axis data;
3:if\(d=2\)then
4: Use \(data_{space}\) to estimate space density \(Den\) at \(points\) with kernel density estimation Formula (34) and the Epanechnikov kernel (36). 5:endif
6:if\(d=3\)then
7: Normalize time data \(data_{ti}\). 8:for\(t=0,2,\dots,19\)do
9:\(time=(i-5)/10\);
10: Use \(data_{space}\) and \(data_{ti}\) to estimate time-space density \(den\) at (\(points\),\(time\)) with (34) and (36). 11:\(Den=Den+den/10\). 12:endfor
13:endif
14:returnDen
```  
**Algorithm 2**Time-space density estimation. In time-space density estimation, there are two options for 2- and 3-dimensional density estimation. Two-dimensional density estimation only considers spatial data to estimate the user's spatial kernel density. Three-dimensional density estimation considers both space and time data, first estimating the spatiotemporal kernel density function and then integrating it into the time dimension. The overall flow of the algorithm is shown in Figure 1.  
On the basis of the above analysis and the time-space density estimation algorithm, the process of solving wireless BS selection-strategy optimization based on trajectory data can be obtained as Algorithm 3.