2018 International Conference on Physics, Computing and Mathematical Modeling (PCMM 2018) ISBN: 978-1-60595-549-0
WiFi Signal Fingerprint Localization Based on KNN
and Particle Filter Fusion Algorithm
An-yi WANG, Jin-hua ZHU and Lu WANG
*School of Communication and Information Engineering Xi’an University of Science and Technology Xi’an, China
*Corresponding author
Keywords: WiFi signal, Fingerprint KNN algorithm, Particle filtering algorithm, Positioning accuracy.
Abstract. WiFi signal fingerprint indoor location usually uses KNN algorithm, but the single
algorithm is prone to accidental error, and the location accuracy of the algorithm is very difficult to meet the indoor positioning needs. Location tracking, a position estimation by the position fingerprint method, the optimal weighted value according to the Kalman filter algorithm, but in front of the non Gauss noise filtering algorithm, Kalman appeared to be inadequate, Monte Carlo particle filtering algorithm to predict particle state is applicable to all nonlinear Gauss noise. In this paper, we tried to match the location fingerprint information by KNN algorithm, and then predicted the particle state and weight by particle filter algorithm to optimize the location results, so as to improve the positioning accuracy of WiFi signal fingerprint location method. The experimental simulation results showed that the positioning accuracy of WiFi fingerprint is obviously improved by selecting the appropriate number of particles through the two algorithms.
Introduction
With the universal coverage of indoor and outdoor wireless access point WIFI signal, WIFI signal positioning technology has emerged based on the indoor positioning technology, the wireless network can not only improve the indoor positioning accuracy based on the traditional, but also to meet the position requirements based on LBS[1], to a certain extent, save the cost, play a key role in the public service. At present, many scholars have proposed a positioning method for WIFI signal intensity of different position, using KNN nearest neighbor algorithm, location fingerprint database and Kalman filtering methods are commonly used algorithm to optimize and improve the indoor positioning accuracy[2], but there are still defects in different degrees. However, both the extended Kalman filter and the Untraced Kalman filter are based on the Gauss state to iterate the results and approach the results. Many practical problems are nonlinear, not Gauss's, and Gauss approximation is still unable to accurately represent the true state distribution. In order to solve the above problem, the positioning result based on KNN algorithm is further implemented by particle filtering algorithm to achieve the accuracy of WIFI fingerprint location[3]. In the particle filter, Monte Carlo sampling is applied, and a set of weighted samples is applied to approximate the real state, and the optimal solution is obtained[4], which makes it suitable for any non Gauss, nonlinear dynamic space.
In order to improve the positioning accuracy of WIFI signal, the simulation results are verified by using the localization method of KNN algorithm and particle filter algorithm.
The Principle of KNN Algorithm
that there are M WIFI hot spots in the scene, a total of N RSS samples are collected, and the training sample data set is expressed as:
r r ri i rN N
I 1,1 , 2,2 ,... , ,... , (1)
Among this, vector
r
i
(
r
i1,
r
i2,...
r
iM)
represents the RSSI vector from the M WiFi hot spot,input the RSSI vector of the target sample at the positioning stage, and calculate the position vector (x, y) by the KNN method. First calculate the similarity of R vector and all the training samples, the maximum similarity and their corresponding coordinates, finally the sample coordinates are weighted to get the ultimate goal, KNN algorithm is used for the prediction of the target sample, calculated between the sample and the distance of all samples. In the indoor environment, the unpredictable change of the signal makes the distance calculation of KNN algorithm also has great error. So in this paper, particle filter is added to improve the accuracy of location based on KNN algorithm. Fig.2 is WiFi fingerprint localization simulation based on KNN algorithm. Simulation experiments show that its indoor positioning accuracy is not very ideal, and it needs to be optimized to reduce positioning error.
1 3 5 7 9 11 13 15 0
0.1 0.2 0.3 0.4
Time of execution for every k(1-15)
0 5 10 15
0.94 0.96 0.98 1
Precision for every k(1-15)
0 5 10 15
0.95 0.96 0.97 0.98 0.99
Precision of Class0 for every k(1-15)
0 5 10 15
0.9 0.92 0.94 0.96 0.98
Precision of Class1 for every k(1-15)
0 2 4 6 8 10 12 14 16 18 20 0
5 10 15
[image:2.595.318.502.299.430.2] [image:2.595.94.283.304.440.2]true trace KNN localization
Figure 1. The relationship between the KNN Figure 2. Location results of KNN algorithm. algorithm and the parameter K. .
WIFI fingerprinting using KNN algorithm of single prediction, need to calculate the target sample and training sample distance, when the number of samples is great, the algorithm will consume a large amount of time, the positioning accuracy and the actual position errors from the simulation can be seen in Fig. 2.
The Principle of Particle Filter Algorithm
Formula Derivation
The idea of Monte Carlo particle filter algorithm source is to appear in an event frequency refers to the event probability generation P(x) to represent the distribution of large sampling. The advantage of the particle filter algorithm is that it can only handle the Gauss distribution unlike the Kalman filter, and it can handle any form of probability distribution[6].
Using the Monte Carlo method to simulate a large number of particles, each particle has a state (position) and weight distribution and weights of all these particles together to simulate the target position (or state) of the probability distribution of all particles can be directly to the state by the weighted average estimated value. The idea of Monte Carlo sampling is to replace the integral with the mean value.
N x f x
f x f
E 1 ... N
n k
N i i n n k
n x x p x y
N y x
p 1: 1 | 1:
1 ) | ( (3) The expected value of the current state of the particle:
N i i n n i n n N i n n k n n n x f N dx x x x f N dx y x p x f x f E 1 1 : 1 1 1 | (4) ResamplingIn the process of applying particle filtering, there is a problem of degradation. After several iterations, the weight of many particles becomes very small and can be ignored. Only a few particles have a larger weight[7]. And the variance of particle weight value increases with time, and the number of effective particles in the state space is less. With the increase of the number of invalid sampling particles, a large amount of computation is wasted on the particles which are almost ineffective in estimating the posterior probability distribution, which makes the estimation performance decline.
The number of effective particles is usually used to measure the degree of degradation of the weight of a particle, that is
)) var( 1
/( *(i)
k
eff N w
N
(5)
k
i k i k k i k i k y x x q y x p w : 1 1 ) ( : 1 ) ( ) *( , | ) | ( (6) In the actual calculation, the number of effective particles can be approximated as:
N i i k eff w N 1 2 ) ( 1 (7) The most direct way to overcome the weight degradation phenomenon of sequential importance sampling algorithm is to increase the number of particles, which will increase the computation amount and affect the real-time performance of computation. Therefore, the following two ways are generally adopted: a. choose the appropriate importance probability density function; b. after sequential importance sampling, the resampling method is adopted.Fusion Localization Based on KNN Algorithm and Particle Filter
Particle Motion Model
The state of the particle changes with the change of the motion model. In the motion model, the direction and position of the particles are constantly changing. The changes in the current direction, the next direction, and the direction of a particle are expressed respectively. The location probability in the next direction of the particle can be expressed as. The current position of the particle, however, is the position at the next moment. Eq. 8 and Eq. 9 represent particle motion models, which represent the current position coordinates of particles respectively, representing the displacement of particles in the motion model, representing the angle of particles at t time.
t t
t t
t
x
x
x
D
x
1
1
cos
t t
t t
t
y
y
y
D
y
1
1
sin
(9)It is impossible for the particle to accurately calculate the posterior probability in real motion, but it can predict its probability value. When the number of particles is relatively large, the posterior probability can be approximated.
n
t t N
n n t t
t
y
w
x
x
x
p
1 : 1
|
(10) Construction of
off-line fingerprint database
Get online RSSI values
KNN algorithm regression
Extracting fingerprint information from the
database
Particle motion state prediction
Particle update
Update particle weight
Estimation of particle position
Particle filtering for KNN location
information
Return to
particle state Iterative first filter
End
[image:4.595.70.449.147.409.2]Sampling
Figure 3. Algorithm flow chart.
Algorithm Implementation and Simulation
The two algorithms shown in Fig.3 are compared with the fusion algorithm respectively. The fusion algorithm of KNN and PF is closer to the actual standard value than that of two algorithms alone. However, an important factor that affects particle filtering is the number of particles. The number of particles is 200, 400, 600, and the location accuracy is as follows. We can draw a conclusion from the experimental results that when N=600 is KNN+PF, the error is the smallest and the mean square error is 1.9833m.
Conclusion
0 5 10 15 20 25 0.5
1 1.5 2 2.5 3 3.5 4 4.5
0 5 10 15 20 25
0 1 2 3 4 5 6
[image:5.595.326.513.75.194.2] [image:5.595.80.253.83.197.2]
Figure 4. Algorithm error contrast diagram for N=200. Figure 5. Algorithm error contrast diagram for N=400.
0 5 10 15 20 25
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
100 200 300 400 500 600 700 2.2
2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1
粒 子 数
平均距离
误差
Figure 6. Algorithm error contrast diagram. Figure 7. The relation between the number of particles and the mean distance error.
References
[1]Cai Minmin. Research on sampling and matching algorithm in indoor location system based on
WiFi fingerprint [D]. Nanjing University of Posts and Telecommunications, 2016.
[2]Liu Jian, Calman. My hole using a linear filter for WiFi-inertial fusion positioning [J].
Electronic Measurement Technology, 2017, 40 (4): 1-4.
[3]Chen Y, Shu L, Ortiz A M, et al. Locating in Crowdsourcing-Based DataSpace: Wireless Indoor
Localization without Special Devices[J]. Mobile Networks and Applications, 2014, 19(4):534-542.
[4]Wu Zetai, Cai Renqin, Xu Shuyan, et al. WiFi positioning research and improvement based on
K nearest neighbor method and improvement of [J]. Computer Engineering, 2017, 43 (3): 289-293.
[5]Chen Bo, Tan Xizhong, Jia Zhenhong, et al. An improved indoor positioning algorithm for
Gauss particle filter [J]. Computer Engineering and Applications, 2017, 53 (14): 246-250.
[6]Wan Hanyong. KNN text classification algorithm based on sample importance principle [D].
Jiangxi Normal University, 2015.
[7]Research on the application of Zhang Xiaoyu. Particle filter algorithm [D]. Hebei University of
Science and Technology, 2009.
[8]Jin Yuzhu, Li Shanji. An improved particle filter resampling algorithm for the study of [J].
[image:5.595.324.513.233.361.2] [image:5.595.83.264.240.359.2]