# Approximating speed from past several lat/lon coordinates

1. Oct 24, 2013

### zpconn

Suppose you are observing the movement of an object on the Earth's surface. At any given moment, you know its current position (in lat/lon coordinates) and three prior positions. Each prior position is separated in time from the one after it by a small but variable number of seconds (say several seconds). For emphasis, the time differences can be different.

Given this information, I want to approximate the current speed of the object in, say, miles per hour, minimizing oscillations in the results. This is a sort of problem of backwards finite differences but I'm struggling to get it right.

I'm currently using the formula

f'(t_0) = [11 * f(t_0) - 18 * f(t_1) + 9 * f(t_2) - 2 * f(t_3)] / 6h

derived from the Taylor series where t_3 < t_2 < t_1 < t_0 and h is the average of the successive time deltas. I'm applying this separately to the latitudes and longitudes to get a tangent vector in lat/lon coordinates per unit time, then converting this into a great circle distance.

This approach is highly inaccurate. I see far fewer oscillations just doing the much more naive

[(great circle distance between current position and last position) / (time between current position and last position)],

ignoring the extra positions I have. This approach still has the occasional oscillation though, and for other reasons I'd like to get a smoother approximation.

Any ideas?

2. Oct 24, 2013

### Staff: Mentor

What's wrong with this approach? It seems to me that simpler and more accurate trumps complicated and less accurate.

How random are the movements of the object and how much variation is there in its velocity? Does knowledge of where the object was in previous time intervals provide a good prediction of where it will be in the next time interval?

3. Oct 24, 2013

### zpconn

I'd love it if the simple approach were working. But it's not quite good enough. The speeds I'm getting seem too volatile. This could be an issue of simply having inherently volatile data, in which case the question becomes more of how to smooth the data without misrepresenting it--I'd welcome suggestions on this as well.

The more complex approach should be *more* accurate for small h, as its error is O(h^3) rather than O(h), but in practice it's less accurate--I figured I had just made an error in the math but perhaps not.

For clarity, I started with the simple approach, found it too volatile, tried the more complex approach, and despite it being theoretically more accurate I found it even less accurate.

4. Oct 24, 2013

### Staff: Mentor

You omit the direction information, this can reduce oscillations. I'm not sure if that is intended.

Longitude and latitude are not completely independent - close to the poles (for for long delays between measurements), the method has to get inaccurate.

Use more data points for the averaging process?

The error might be O(h^3) if your taylor coefficients are perfect, but if they come from data this is not true.

5. Oct 24, 2013

### zpconn

Using more data points is actually problematic as only so many are available at any given moment. Usually up to three are available (in addition to the current location), occasionally fewer, and possibly sometimes more (but that's certainly not typical).

I suppose I could try something really simple like taking the past three points in addition to the current one and just averaging the three calculated speeds. I have no experience with data smoothing and am not sure if there are, well, less naive methods of doing this.