# S-PDR: SBAUPT-Based Pedestrian Dead Reckoning Algorithm for Free-Moving Handheld Devices
## 3 SBAUPT-Based Pedestrian Dead Reckoning (S-PDR)
### Heading Estimation
#### 3.3.1 Outlier Rejection and Statistical Heading Estimation  
To enhance the estimation of the heading, outlier measurements in the step window need to be filtered out. The walking behavior of pedestrians includes a swaying motion as the user switches between right and left steps, this is part of the balancing process to maintain the center of gravity of the body. This motion can cause low acceleration periods of the step to deviate far from the true heading of the step and hence are considered outliers. The heading estimation is hence mainly targeting the high acceleration/deceleration stages of the step. As per previous elaborations, the usual step is similar to a sinusoidal wave including a peak and valley pair that are both positive values due to the shift by the gravity vector. When the signals are leveled and compensated for gravity, the east and north accelerations  
Figure 8: In\(-\)step headings from horizontal linear accelerations. Figure 7: In\(-\)step linear accelerations vectors direction. components are nearly zero mean sinusoidal waves, and when the magnitude of the total horizontal acceleration is computed it results in inverting the valley part of the signal to a peak. Hence, the selection of the accelerations is based on a window of measurements from the two peak values in the horizontal accelerations' components. The window around the first peak is representative of the forward direction of motion, while the window around the second peak is representative of the reverse direction of motion deceleration section of the step. The region of interest in the acceleration window is shown in Figure 9 based on magnitude filtering around the peak values, and the corresponding acceleration vectors in the east/north plane are shown in Figure 10. Finally, the in-step headings with encircled headings of interest corresponding to the selected accelerations from the measurements window are shown in Figure 11.  
Figure 10: In–step east vs. north accelerations scatter. Figure 9: In–step accelerations regions of interest. The dominant heading angle can be verified by further analysis of the in-step headings using a histogram, where the expected outcome is to have a peak bin in the histogram representing the direction of motion, and another peak bin that is 180 degrees (\(\pi\)) away from the first peak representing the direction of deceleration. To resolve the ambiguity of which of the two bins represent the forward direction, the accelerations in each bin are matched back to the original accelerations signals and the bin containing the acceleration samples from the first half of the step--which is the accelerating phase of the step in the direction of motion--is the bin representing the forward motion. The distribution of the previously presented headings is illustrated in Figure 12, where there is a dominant bin at heading 2 radians and another at nearly \(-1.4\) radians. In some cases, the true heading will be borderline between two bins and the recorded headings will be split over two bins, hence we expand the selection to take into account the direct neighbor to the left or right based on a selection criterion. The histogram distribution is constructed with bins of width \(0.1\pi\) radians resulting in 20 bins. After distinguishing the first dominant bin, the direct neighbors of the bin are examined to decide if one of them will be included in the heading computation. The right and left neighbors are inspected, and the neighbor with the greater number of measurements per bin is chosen as a candidate bin to be merged with the dominant bin. If the candidate bin has a number of measurements that is higher than a certain threshold, it will be merged with the dominant bin. Once the dominant bin and possible direct neighbor is/are distinguished, the remaining bins in the forward phase are discarded and the search for the second dominant bin  
Figure 11: In–step headings of interest. Figure 12: In–step heading distribution histogram. starts.