Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am working on a simple application that allows the user to do a lot of different things with a GPX file (GPS track). Some things computed are: average speed, max speed, etc. The max speed values I'm getting are very unrealistic, and when I look at a plot of the data, it's clear that there are spikes that represent inaccuracies. See the image below, which was a snowboarding run I did the other day... there are two spikes of ~57mph and 70mph, which I know are inaccurate.

enter image description here

I'm a bit rusty on my statistics, but I know there are probably multiple approaches to filtering/smoothing/correcting this data to remove the erroneous values, while retaining the quality I desire.

What is the best approach to accomplish that goal, and why?

A quick explanation of how the values in the plot are generated: each point logged by the GPS unit contains latitude/longitude values and a time value. Using the spherical law of cosines, the distance between any neighboring points in the track can be calculated, and that along with the time elapsed gives the average speed for the segment between those two points. This is repeated for each set of neighboring points in the track to generate the plot above. Obviously the inaccurate speed values are a result of positioning error from the GPS unit... if it logs me too far backward for one logged point, and then too far forward for the next point, the distance covered in that segment is calculated as much higher than it really was, and therefore so is my speed. In the segment leading up to the highest spike in the plot above, I supposedly increased my speed from ~12mph to 70mph over a segment of 100ft.

share|improve this question
1  
your question might be better answered on stackoverflow.com - here are some relevant links: stackoverflow.com/questions/1134579/smooth-gps-data, stackoverflow.com/questions/9311168/smooth-of-series-data. basically, the idea is to use either a Kalman filter or a moving average, depending on your needs. –  Vincent Tjeng Mar 1 '13 at 2:54
    
@VincentTjeng thanks for the link. I'd actually already come up with using a moving average on my own (5 points seems to work pretty well), but I figured I'd see what else was out there. Looks like if I'm serious I'll have to dig deep and learn about the Kalman filters. Thanks. –  The111 Mar 1 '13 at 3:04
    
> "two spikes of ~57mph and 70mph, which I know are accurate". I would guess that you mean "inaccurate", unless you're a much better snowboarder than I am. –  bubba Mar 1 '13 at 4:06
    
@bubba yes that was a typo, thanks. ;-) –  The111 Mar 1 '13 at 8:48
add comment

1 Answer

up vote 1 down vote accepted

Using a moving average seems reasonable. It's quick, easy, and will probably do what you want. There are lots of variations , but a simple calculation that replaces each value $v_i$ by the average of $v_{i-2}$, $v_{i-1}$, $v_i$, $v_{i+1}$, $v_{i+2}$ will probably work fine. If the result still looks too rough, expand to 7 points.

share|improve this answer
    
Yeah, that's what I'm doing for now. Some day I'll try to learn about Kalman filters and it will be interesting to compare the results, but for now I'll probably leave it like this. Thanks. I'll accept your answer unless a better one gets posted. :-P –  The111 Mar 1 '13 at 8:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.