# A Real-Time BLE/PDR Integrated System by Using an Improved Robust Filter for Indoor Position
## 3 Materials and Methods
### A Robust Filter Model  
The EKF model described above can effectively suppress the drift error of the PDR method and improve the overall positioning accuracy and stability, but the effect of suppressing the gross error of the BLE fingerprint position is poor. This paper proposes a robust filter model. In the EKF model, the innovation vector \(r_{k}\) is expressed as Equation (32):  
\[r_{k}=Z_{k}-H_{k}\cdot X_{k}=\big{[}N_{k}^{\prime}-N_{k},E_{k}^{\prime}-E_{k} \big{]}=[\Delta N,\Delta E] \tag{32}\]  
where \(\Delta N\) and \(\Delta E\) represent the position coordinate difference in the north and east, respectively. From Equation (32), the \(r_{k}\) represents the position coordinate difference between the BLE and PDR methods. When there are gross errors in the positioning method, there are the following situations:  
1. The difference \(\Delta N\) exceeds the limit;
2. The difference \(\Delta E\) exceeds the limit;
3. The innovation vector \(r_{k}\) exceeds the limit, \(\Delta N\) and \(\Delta E\) are within the acceptable range;
4. The difference \(\Delta N\), \(\Delta E\), and the innovation vector \(r_{k}\) exceed the limit. Therefore, to judge whether there is a gross error in the process of position, it is necessary to determine the distribution of the \(\Delta N\), \(\Delta E\) and \(r_{k}\). In the EKF method, \(Z_{k}\) should conform to Gaussian distribution with mean \(H_{k}X_{k}\) and covariance \(P_{k}^{r}\) as shown in Equation (33). The innovation vector \(r_{k}\) conforms to Gaussian distribution with mean 0, covariance \(P_{k}^{r}\). \[P_{k}^{r}=H_{k}\cdot P_{k}^{-}\cdot H_{k}^{T}+R_{k} \tag{33}\]  
while the difference \(\Delta N\) conforms to the Gaussian distribution with mean 0, covariance \(\delta_{\Delta N}^{2}\) and the difference \(\Delta E\) conforms to the Gaussian distribution with mean 0, covariance \(\delta_{\Delta N}^{2}\). \[\delta_{\Delta N}^{2}=\big{[} \begin{array}{cc}1&0\end{array} \big{]}\cdot P_ {k}^{r}\cdot\big{[} \begin{array}{cc}1\\ 0\end{array} \big{]} \tag{34}\]  
\[\delta_{\Delta E}^{2}=\big{[} \begin{array}{cc}0&1\end{array} \big{]}\cdot P_ {k}^{r}\cdot\big{[} \begin{array}{cc}0\\ 1\end{array} \big{]} \tag{35}\]  
\[\lambda_{\Delta N}=\Delta N\;\sim\;N\Big{(}0,\delta_{\Delta N}^{2}\Big{)} \tag{36}\]  
\[\lambda_{\Delta E}=\Delta E\;\sim\;N\Big{(}0,\delta_{\Delta E}^{2}\Big{)} \tag{37}\]The squared Mahalanobis distance \(M_{k}\) of \(r_{k}\) conforms to the chi-square distribution \(\chi^{2}_{m,\alpha}\) with the freedom \(m\) which is the dimension of the observation \(Z_{k}\). \[\lambda_{r}=M_{k}^{2}=r_{k}^{T}(P_{k}^{r})^{-1}r_{k}\ \sim\ \chi^{2}_{m,\alpha} \tag{38}\]  
The chi-square distribution \(\chi^{2}_{m,\alpha}\) is constructed to determine whether the actual vector \(r_{k}\) calculated in the EKF exceeds the limit under the Gaussian assumption. Significance level \(\alpha\) is the probability threshold and 5% is adopted in our research. \[P_{r}\Big{[}\lambda_{r}>\chi^{2}_{m,\alpha}\Big{]}<\alpha \tag{39}\]  
where \(P_{r}\) represents the probability of a random event that the probability of \(\lambda_{r}\) being larger than \(\chi^{2}_{m,\alpha}\) is very small. Hence, if the actual \(r_{k}\) is larger than the \(\alpha\)-quantile, the null hypotheses are rejected and it can be concluded that \(r_{k}\) exceeds the limit and \(Z_{k}\) has a gross error in the positioning. For \(\Delta N\) and \(\Delta E\), when the actual measurements are larger than twice the corresponding standard deviation, the significance level is less than 5%, and it can be concluded that \(\Delta N\) or \(\Delta E\) or both exceed the limit and \(Z_{k}\) has a gross error. When the vector \(Z_{k}\) has a gross error, the observational covariance matrix \(R_{k}\) should multiply a robust vector:  
\[\overline{R}_{k}=\beta_{k}^{T}\cdot R_{k}\cdot\beta_{k} \tag{40}\]  
where \(R_{k}\) represents vector. \(\overline{R}_{k}\) is the modified observation covariance matrix.