TL;DR
Trajectory prediction estimates where a moving agent, such as a car, a cyclist or a pedestrian, will be over the next few seconds, using its recent positions and the scene around it. Because an agent can go straight, turn or stop, good models do not return a single path. They return several possible futures, each with a probability, so that a planner can prepare for the likely ones.
Builds on: Time Series Forecasting, Recurrent Neural Network, Mixture Density Network · Leads to: VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation
Where it's used
Self-driving cars. A planner has to know what nearby vehicles and pedestrians will do in the next few seconds before it picks its own path. The Argoverse motion forecasting benchmark, released in 2019 by Argo AI with university partners, gives each model two seconds of past positions sampled ten times per second and asks for the next three seconds, for many agents in each city scene.
Crowds. Stations, malls and sidewalks are full of people who avoid each other. The ETH and UCY benchmarks hold pedestrian tracks from five outdoor and indoor scenes. The standard protocol gives a model 3.2 seconds of history and asks it to predict 4.8 seconds ahead. Crowd models must learn that a pedestrian ahead will step aside, not only that the pedestrian keeps walking.
Robots that share space. A warehouse robot in an aisle with people, or a drone avoiding a moving object, uses the same forecasts to slow down before a conflict forms rather than after it. The forecast is only useful if it arrives early enough for the robot to change course.
How it works
Follow one agent that moves to the right. Positions are in metres and time steps are one second apart.
- Input. The model sees three past positions: at time 1 the agent is at (0, 0), at time 2 at (1, 0), at time 3 at (2, 0). Check: each step moves the agent by (1, 0), so its speed is 1 metre per second and it has not turned.
- Encode the history. A recurrent network reads the positions one at a time and keeps a hidden state that is updated at each step. After reading the third position the hidden state summarises "moving right at about 1 metre per second, no turn yet". Check: if the agent had stopped, the same network would store a different summary, which is why the state must depend on the whole history.
- Decode the future as a mixture. From the hidden state, the model outputs a small set of components. Each component has a weight, a mean position and a spread. For the next position (time 4) the model says: with weight 0.8 the agent continues straight, centred at (3, 0); with weight 0.2 it turns up, centred at (3, 1). Check: the two weights sum to 1, so they are probabilities.
- Score the outcome. Training asks how likely the true next position was under the mixture. If the agent really went to (3, 0), the straight component gives that point most of the probability, so the loss is small. If it went to (3, 1), the turn component gives it some probability, so the loss is larger but not infinite.
- Roll it out. For a forecast, the model repeats steps 2 to 4 for every future step, or outputs all future steps at once. The result is a bundle of plausible paths rather than one line, and each path can be given to the planner with its probability.
flowchart LR A[Past positions] --> B[Recurrent encoder] B --> C[Decoder outputs weights, means, spreads] C --> D[Mixture of Gaussians over each future step] D --> E[Sample or rank several futures]
The plot below is a one-dimensional version of a two-component mixture, with its own numbers rather than the ones from the walkthrough. The two dashed bumps are the components, and the solid curve is their weighted sum. The next position is most likely near 0 but still has a chance near 4.
- 0.6 component at 0
- 0.4 component at 4
- mixture
The math
Given past positions in , a mixture density forecast is a probability density over the future positions of the form , a weighted sum of Gaussians. Here are weights that sum to 1, each is a mean position, and each is a covariance matrix. The index runs over future steps and is the number of modes.
Step 1 in symbols: the history
Write the position at time as and the velocity as . In the example, , and , so .
Step 2 in symbols: the hidden state
A simple recurrent encoder computes for each , with learned matrices , and a bias . The final state is the summary that the decoder reads. (See Recurrent Neural Network and Long Short-Term Memory for gated versions.)
Step 3 in symbols: the mixture weights
The decoder produces raw scores for each component and turns them into weights with the Softmax, , so that the weights are positive and sum to 1. The example uses for the straight and turn modes.
Step 4 in symbols: the training loss
Training minimises the negative log-likelihood of the observed future, . Maximising the likelihood of the data is the principle behind Maximum Likelihood Estimation.
Step 5 in symbols: the error measures
Let be the forecast for step and the truth, with future steps. The average displacement error is , and the final displacement error is . When a model returns sampled futures, minADE keeps the best of the at each example, which rewards a model for putting one good guess among its samples.
Worked examples
Observed positions are , , . The true future is and .
- Velocity: .
- Forecast for time 4: .
- Forecast for time 5: .
- Error at time 4: .
- Error at time 5: .
- ADE . FDE .
Interpretation: a baseline that assumes no turning is right until the agent turns, and its error appears at the far end of the forecast, which is why FDE is reported next to ADE.
Use a one-dimensional mixture with , means and spreads . Let , so and .
- Density at : .
- Negative log-likelihood at : .
- Density at : .
- Negative log-likelihood at : .
Interpretation: the outcome near the likely mode costs less. The turn outcome at 4 is not ruled out; it costs more, but the loss stays finite, which is what lets a mixture learn that both outcomes happen.
A car moves at 12 metres per second and the forecast horizon is 3 seconds. The straight mode puts the car at (36, 0) metres ahead of its present position with weight 0.7. The turn mode puts it at (30, 8), into a driveway on the left, with weight 0.3. The car turns.
- Distance covered at constant speed: metres, the straight endpoint.
- Single straight forecast, endpoint error: metres, so FDE .
- Two-mode forecast, the turn mode is one of the guesses and matches the truth exactly, so minFDE .
- Interpretation: the single-mode forecast fails by 10 metres at the moment the planner most needs the answer. Keeping the turn mode, even at weight 0.3, lets the planner brake for the driveway.
- Try it: a pedestrian walks at 1.4 metres per second and the horizon is 4 seconds. How far from the current position is the constant-velocity forecast at the end of the horizon? Answer: metres.
Common mistakes and tradeoffs
It is tempting to think that a forecast should be one best path. In fact the future of an agent is multimodal, because a driver can turn or not turn, and a single averaged path lands between the modes where no agent goes. A single mean, trained with squared error, lands between the modes, because the average of the two outcomes is the answer that minimises squared error.
It is tempting to think that a lower average error means a better model. In fact ADE can hide a model that misses the rare turn, which is the case a planner must not miss. Report minADE or minFDE over a set of guesses together with the miss rate, not only the mean error.
It is tempting to think that a learned model always beats physics. In fact, over a short horizon, a constant-velocity or constant-acceleration model with a Kalman filter is hard to beat and costs almost nothing. Learned models pay off when the horizon is longer and the agents react to each other or to the road.
It is tempting to think that more input is always better. In fact anything recorded after the prediction time, such as the agent's full future route, leaks the answer into the input. Results look excellent and then fall apart in deployment, because the information is not available when the car needs it.
When to use it. Several agents interact, the horizon is seconds long, and what an agent intends matters, as on roads, in crowds and around robots.
When not to use it. Single agents on short horizons, or when a physics model is already accurate enough.
| Option | Strength | Weakness |
|---|---|---|
| Constant velocity with a Kalman filter | Cheap, strong for short horizons | Cannot represent turns or interaction |
| Recurrent encoder with a mixture head | Multimodal, simple to train | Sees only the agent, unless extended |
| Transformer with scene context | Uses maps and neighbours together | Needs more data and compute |
History
Before learned models, tracking systems predicted motion with linear filters. Rudolf Kalman's 1960 paper on linear filtering and prediction gave the standard constant-velocity tool that many systems still use as a baseline.
Neural networks with a probabilistic output head came from Christopher Bishop's 1994 work on mixture density networks, which made a network output the parameters of a mixture. Alex Graves used the same idea in 2013 to generate handwriting from a recurrent network, which showed that a mixture head could model smooth sequences with sudden changes.
Social LSTM (Alahi et al., 2016) brought the idea to crowds. Each pedestrian had its own recurrent network, and a pooling step shared the hidden states of nearby pedestrians, so that one person's plan could depend on the people around them. Benchmarks such as ETH and UCY and later Argoverse made the comparison of methods concrete, and models that encode maps and neighbours together became the common approach for driving.
Recap
- The goal is a distribution over future positions, not one path.
- A recurrent encoder turns the observed history into a hidden state that summarises it.
- A mixture of Gaussians head turns that state into weights, means and spreads for each future step.
- Training uses the negative log-likelihood of the true future; evaluation uses ADE, FDE and minADE over several guesses.
- Read next: VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation, which encodes the map and the agents as vectors, and Attention Mechanism for how modern models let agents attend to one another.
Check yourself
QuestionRecall: what do ADE and FDE each measure, and which one emphasises the far end of the forecast?Show answer
ADE is the average Euclidean distance between forecast and truth over all future steps. FDE is the distance at the last step only. FDE emphasises the far end of the forecast because it ignores the earlier steps, where errors are usually small.
QuestionAn agent is last seen at (5, 5) metres and moves (2, 1) metres per step. Using constant velocity, where is the forecast three steps later?Show answer
Constant velocity adds three copies of the velocity to the last position: . The forecast is at (11, 8) metres.
QuestionWhy does a mixture of Gaussians fit trajectories better than a single Gaussian?Show answer
A single Gaussian has one peak, so it places its mass between two distinct outcomes, such as going straight and turning, where neither outcome happens. A mixture can put separate peaks on each outcome and give each a weight, so the likely futures are represented without averaging them into an impossible middle.
QuestionA forecaster gives straight weight 0.9 and turn weight 0.1. The car turns. Is the forecast useless for planning?Show answer
Not necessarily. The forecast assigned a real probability to the turn, so the planner can keep a turn candidate in its plan and react early when the car starts to turn. The forecast is poorly calibrated if the car turns often, which is a reason to check calibration on data, not a reason to discard the mixture.
Sources
- Alahi et al., "Social LSTM: Human Trajectory Prediction in Crowded Spaces", CVPR 2016.
- Graves, "Generating Sequences With Recurrent Neural Networks", 2013.
- Argoverse, 2019 (motion forecasting benchmark).