# WiFi FTM, UWB and Cellular-Based Radio Fusion for Indoor Positioning
## 3 Materials and Methods
### Maximum Likelihood Estimator (MLE)  
Ranging information is uncertain because measurements are never ideal. Least squares (LS) estimation solves over-determined systems even though they are inconsistent since it is not possible to find a solution. The idea is to find a solution which minimises the error of the system. However, the classical iterative LS method for positioning lacks robustness; even a single outlier can introduce a great error in the estimated target position. This problem increases when the final accuracy should be reduced to the sub-meter accuracy. In [10], WLS was used to compute the location with trilateration, but to avoid the problem of outliers, the ranges were weighted according to their precision. A higher weight was assigned to UWB (which is more precise) than LTE. However, these weights were assigned statically; so, if a specific device introduced a high-precision ranging error (due to factors such as an especially challenging location for propagation, or software and hardware malfunctions), the localisation accuracy would be considerably affected. Maximum likelihood estimator (MLE) is the most popular estimator for obtaining the parameter \(\hat{\theta}\), which specifies a probability function \(P(X=x|\theta)\) or a probability density function \(p(X=x|\theta)\) of a discrete or a continuous variable based on the observations \(x_{1},x_{2},\ldots,x_{n}\) which are independently sampled from the distribution [25]. In this work, MLE weights the ranges provided by different reference points in real-time depending on the variation of the error attached to the ranges. The system stores the error associated to each RP iteratively with a temporal window and weights the sources by their standard deviation. Supposing that \(\mathbf{X}=\{X_{1},X_{2},\ldots,X_{n}\}\) with distribution \(F_{\theta}\) being \(\theta=\{\theta_{1},\theta_{2},\ldots,\theta_{n}\}\) that follows the density function \(f_{\theta}(x)\)[26]. Hence, the likelihood function of the observation is given by:  
\[L(\theta;\mathbf{X})=\prod_{i=1}^{n}f_{\theta}(X_{i}) \tag{1}\]  
The MLE estimates the best candidate that optimally maximises \(L\) as seen below:  
\[\hat{\theta}=argmax(log(L(\theta;\mathbf{X}))) \tag{2}\]  
Hence, assuming that observations follow a Gaussian distribution, the estimator calculates the parameters of mean and standard deviation that best suits Equation (2). In this work, MLE dynamically weights the different reference points at the WLS algorithm. Once the target's position is estimated, the distances \((\mathbf{\hat{d}_{est}}=\{d_{est1},d_{est2},\ldots,d_{estn}\})\) from the estimated position to each RP positions are calculated. Then, the estimated error of each RP (\(\mathbf{\hat{e}_{est}}=\{e_{est1},e_{est2},\ldots,e_{estn}\}\)) between the estimated distances \((\mathbf{\hat{d}_{est}})\) and the input distances (initially for the LS algorithm) are obtained. Finally, MLE provides the weight values of each RP based on the error (\(\mathbf{\hat{e}_{est}}\)) from the last \(N\) time epochs. The value of \(N\) depends on the periodicity that the measurements are captured. We store the \(N\) elements that were captured in the last 5 s. Figure 2 represents the weighted values of different reference points during an experiment. In this case, it can be observed that a WiFi AP is overweighted for some epochs. Then, owing to a blocking of line of sight between the target and the WiFi AP, the weight of the WiFi AP is reduced drastically due to the precision of the range being reduced to the level of lower precision technologies such as LTE base stations (BSs). Thus, the system benefits from the most stable and precise ranges. When the MLE receives a new input source (i.e., a new RP and its distance), the estimator assigns a low weight during the first \(N\) epochs in order to check the stability of the new source. In case a RP data are not captured, the MLE erases the stored data of that RP. Once all the information is weighted, WLS algorithm utilises the weights to provide the best target position.