(4) Particle resampling based on adaptive particle number

In order to reduce the amount of calculation and avoid unnecessary resampling, judge whether resampling is required according to the effective particle number *Neff* . The equation for calculating the effective value of particles is

$$N\_{eff} = 1 / \sum\_{i=1}^{N} \left( w\_k^i \right)^2 \tag{16}$$

The smaller the number of effective particles is, the more serious the particle weight degradation is, and the there is more need to resample. Set the resampling threshold *Nth*, when *Neff* <sup>≤</sup> *Nth*, particle set *xi <sup>k</sup>*, *<sup>w</sup><sup>i</sup> k* needs resampling.

Theoretically, the larger the number of particles, the more accurate the results of PF. However, as the number of particles increases, the calculation time increases exponentially, and the improvement of navigation and positioning accuracy is not obvious, especially for the navigation and positioning results under the condition of the known initial position and heading. For position under the condition of unknown initial position and heading, a large number of particles are required at the beginning. Using a large number of particles after finding the location of a pedestrian in the map will lead to computational inefficiency. Therefore, this paper proposes a method to adaptively adjust the particle number during resampling, which can greatly improve the computational efficiency of PF and ensure the high-precision navigation and positioning results of pedestrian navigation system. The calculation equation of the adaptive particle number is

$$pNum = floor(e \cdot c\_1) + c\_2 \tag{17}$$

In Equation (17), *floor* is the integral function, and *e* is the sum of the main diagonal elements of the covariance matrix of the position coordinates of all particles at the current moment. *c*<sup>1</sup> and *c*<sup>2</sup> are empirical constants. *c*<sup>1</sup> is the proportional coefficient, and the value of *c*<sup>2</sup> ensures that the particle filter function can be achieved when *pNum* is at the minimum value. In this paper, *c*<sup>1</sup> and *c*<sup>2</sup> are 1000 and 2000, respectively.

The updated particle set is recorded as *xi k*, 1/*pNum* .
