Brief
A GPS log is a list of positions with timestamps, about one per second. Speed is not in that list. You get it from the derivative of position: how fast position changes, in the limit of a tiny time step.
With samples you can't take the limit, so you use a finite difference. The forward difference has an
error that shrinks like . The central difference looks at one sample on each side, and its error
shrinks like . numpy.gradient uses central differences inside the array and one-sided ones at the ends.
The catch is noise. GPS positions jitter by a few metres. A difference divides that jitter by , so a 3 m wobble over one second looks like several metres per second of fake speed, and a smaller makes it worse. The fix is to fit a smooth curve to a window of samples with least squares, then differentiate the fit. A wide window kills the noise but also flattens real peaks, like the moment you brake hard. This project is about finding that balance and measuring it.
To turn latitude and longitude (in radians) into metres near a reference point, use and with km.
DATA · your phone's GPS export or a public track
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- On the noisy synthetic track, your speed RMSE is lower than `numpy.gradient` on the same data. Record both with `python tools/mlarena.py record BM-13 "<yours> vs <np.gradient> m/s"`.
- Your top speed is within 5% of the true top speed, so the smoothing did not flatten the peaks.
- The README shows speed and acceleration curves for a real GPS log.
Side quests
Terms in plain words
- Derivative
- The rate of change at one instant. Speed is the derivative of position with respect to time.
- Finite difference
- An estimate of a derivative from samples: the change in value divided by the change in time.
- Central difference
- [s(t+h) − s(t−h)] / 2h. It uses one sample on each side, and its error shrinks like h², while the forward difference shrinks only like h.
- Noise amplification
- A difference divides measurement noise by a small h. Halve h and the noise in the speed roughly doubles.
- Savitzky–Golay filter
- Fits a small polynomial to a sliding window of samples by least squares and takes the derivative of the fit.