Probability for Robotics · Theory · M1
M1-T1 — Why Robots Need Probability
A robot never knows where it is. It knows how sure it is, and that is enough to act well.
Tell a robot to drive two metres and measure where it stops. Do it ten times and you get ten different answers. Nothing is broken: wheels slip, sensors are noisy and the floor is not the floor of the model. This lesson explains where that uncertainty comes from, what it means to put a number on it, and why a robot that carries only a best guess makes worse decisions than one that also carries its doubt.
Learning objectives
After this lesson, you should be able to:
- Name the five sources of uncertainty in a robot and give an example of each.
- Explain what a probability means in two ways: as a long-run frequency and as a degree of belief.
- Distinguish a state, an estimate, an error and an uncertainty.
- Show with an expected-cost calculation why the most likely state can lead to the wrong action.
The intuition
Rover, the small two-wheeled robot of this course, is told to drive 2.00 m along a corridor. You mark where it stops and repeat the run ten times. The marks are spread over several centimetres. The command was the same every time, so the spread comes from things the command does not control.
| Source | What happens | Example on a mobile robot |
|---|---|---|
| Actuation | The robot does not do exactly what it was told. | A wheel slips on dust; one motor is slightly stronger; a drone is pushed by a gust. |
| Sensing | A measurement differs from the true quantity. | A range reading scatters by a few centimetres; an encoder counts in whole ticks; a camera pixel is 3 cm wide at 5 m. |
| Environment | The world is not what the robot assumes. | A door that was open is closed; a person walks through the scan; a glass wall returns no echo. |
| Model | The equations are a simplification. | The wheel radius is 2% off; the floor is assumed flat; the sensor noise is assumed Gaussian and is not. |
| Computation | The algorithm is approximate and late. | A map is a grid of 5 cm cells; a filter linearizes a curve; a measurement arrives 40 ms after it was taken. |
None of these can be removed completely. A better sensor makes the spread smaller, not zero. So the honest description of what Rover knows after its drive is not “I am at 2.00 m” but “I am probably within a few centimetres of 2.00 m, and almost certainly within ten”. Probability is the language that makes that sentence precise.
What a probability means
A probability is a number between 0 and 1 attached to a statement. There are two ways to read it, and a robotics engineer uses both.
- Long-run frequency. “The probability that Rover docks is 0.9” means: repeat the drive many times under the same conditions and about 90% of the runs end on the dock. This reading describes the robot and its world. You can measure it with an experiment.
- Degree of belief. “The probability that Rover is in the kitchen is 0.9” is about one situation, now. Rover either is in the kitchen or is not; nothing is repeated. The number describes what the robot knows: how strongly the evidence it has supports the statement. New evidence changes the number even though the robot has not moved.
The two readings obey exactly the same rules (the next lesson states them), which is why the same mathematics serves for testing a robot over a thousand runs and for running a filter inside it.
Best guess and belief
Suppose Rover's range sensor says the door ahead is 0.60 m away. A program that stores the single number 0.60 has thrown away something it knew: that the sensor is good to about 10 cm, so the door might be at 0.50 m or 0.70 m. A program that stores a belief keeps the whole picture: every possible distance, with a weight that says how plausible it is.
A belief is not vagueness. It is a precise, numeric statement of what the robot does and does not know, and it is the input every decision in this course will use.
Definitions
- State
- The true value of the quantities you care about: here the distance to the door; later a pose , a velocity, a map. The robot never observes it directly.
- Measurement
- What a sensor reports. It depends on the state, but it is not the state.
- Estimate
- A single number the robot computes as its best guess of the state.
- Error
- The difference between the estimate and the truth. It is one unknown number: if the robot knew it, it would subtract it.
- Uncertainty
- A description of the errors that are possible and how likely each is. It is known even though the error is not. A standard deviation of 0.10 m is an uncertainty.
- Probability
- A number in attached to a statement : 0 means “cannot be true”, 1 means “certainly true”.
- Belief
- The robot's probability for each possible state, given everything it has measured and commanded so far.
Written with the notation used in the rest of the course, the belief at time is a conditional probability: the probability of the state given the data.
Two kinds of uncertainty behave differently, and it is useful to keep them apart:
- Noise (also called aleatoric uncertainty) is the scatter that remains however much you know: the next range reading will differ from this one. Averaging reduces its effect; nothing removes it.
- Ignorance (epistemic uncertainty) is what you could know but do not: the wheel radius, where the robot was switched on, whether the door is open. More data shrinks it.
Derivation: when the best guess gives the wrong action
Why carry a belief at all? Because the action that is best for the most likely state is not always the best action. The argument takes four lines.
Rover approaches the door and must choose between two actions: continue at speed, or slow down. There are two possibilities for the world: the door is closer than the stopping distance (call this , for hazard), or it is not. Rover's belief gives . Each action has a cost in each case:
| Hazard (probability ) | No hazard (probability ) | |
|---|---|---|
| Continue | collision, cost | nothing lost, cost 0 |
| Slow down | safe, cost | time lost, cost |
The expected cost of an action is each cost multiplied by its probability, added up. It is the average cost per approach if the same situation were met many times.
Slowing down costs the same lost time whether or not the hazard was real.
Choose the action with the smaller expected cost.
Divide both sides by . The threshold depends only on the ratio of the two costs.
Now compare with a robot that uses only its best guess. If the most likely state is “no hazard”, and for that state the best action is to continue. So the best-guess robot continues whenever . The belief robot slows down whenever . If a collision is fifty times worse than a lost second, that threshold is 0.02. For every belief between 2% and 50% the two robots disagree, and the best-guess robot is the one that eventually hits the door.
The best guess answers “what is most likely?”. A decision needs “what could happen, how likely is it, and what would it cost?”. Only a belief can answer that.
A worked example
Put numbers on the figure above. The range sensor reads m and its noise has a standard deviation of m. At the current speed Rover needs 0.45 m to stop. A collision costs and slowing down costs (in any unit, for example seconds of delay).
- Best guess. The estimate is 0.60 m and the stopping distance is 0.45 m, so there is a margin of 0.15 m. The best-guess robot continues.
- Belief. Treat the belief about the true distance as a bell-shaped (Gaussian) curve centred on 0.60 m with standard deviation 0.10 m. Module 2 studies this curve; here we only need the area of its left tail.
- Probability of the hazard. The hazard is . That is standard deviations below the centre. The area of a Gaussian below −1.5 standard deviations is 0.0668, so : about one approach in fifteen.
- Threshold. .
- Decision. : slow down. In expected cost, continuing costs per approach and slowing down costs 1.
- How close may Rover get at this speed? The hazard probability falls to 0.02 when the reading is m. Below a reading of 0.655 m the robot should already be slowing: a margin of about two standard deviations, not zero.
The same calculation with the course library. Every number above is printed by this program, and the site's tests run it.
from robotprob import gaussian_cdf, gaussian_ppf
z, sigma = 0.60, 0.10 # reading and its standard deviation (m)
stop = 0.45 # stopping distance (m)
C_c, C_s = 50.0, 1.0 # cost of a collision, cost of slowing down
p = gaussian_cdf(stop, z, sigma) # P(true distance < stopping distance)
p_star = C_s / C_c
print('P(hazard) =', round(p, 4))
print('threshold =', round(p_star, 4))
print('cost if continue =', round(p * C_c, 2))
print('cost if slow down =', round(C_s, 2))
print('decision =', 'slow down' if p > p_star else 'continue')
print('slow below reading =', round(stop - gaussian_ppf(p_star) * sigma, 3), 'm')P(hazard) = 0.0668 threshold = 0.02 cost if continue = 3.34 cost if slow down = 1.0 decision = slow down slow below reading = 0.655 m
gaussian_cdf(a, mean, std) is the probability that a Gaussian quantity is below a; gaussian_ppf is its inverse.In robotics
Every part of a robot's software that touches the real world carries uncertainty, and the rest of this course is about the tools each part uses.
| Task | What is uncertain | How probability is used | Where in this course |
|---|---|---|---|
| Localization | The robot's pose | A belief over poses, updated by every motion and every measurement | Modules 6 to 9 |
| Sensor fusion | Each sensor's reading | Readings are weighted by how certain they are; a noisy sensor counts for less | Modules 4 and 7 |
| Mapping | Whether each piece of space is occupied | A probability of occupancy per cell, raised or lowered by each beam | Module 10 |
| SLAM | The trajectory and the map together | The most probable trajectory given all measurements, found by optimization | Module 11 |
| Planning and safety | Where the robot and the obstacles really are | Margins sized from the pose uncertainty; actions chosen by expected cost, as above | Module 12 |
Three concrete places you will meet it in practice:
- Messages carry it. In ROS 2 the pose and velocity messages used by localization (
geometry_msgs/PoseWithCovariance, insidenav_msgs/Odometry) include a 6 × 6 covariance matrix next to the estimate. A consumer that ignores it is the best-guess robot of this lesson. Module 4 explains how to read that matrix. - Flight controllers gate on it. A drone's state estimator compares each new measurement with what it expected and rejects one that is improbably far off, for example a GPS jump. “Improbably far” is defined by the estimator's own uncertainty. The UAV course describes this for PX4 and EKF2; modules 7 and 8 build the mathematics.
- Humanoids and manipulators need it at contact. Whether a foot is firmly on the ground or a part is seated in a fixture is never observed directly; it is inferred from noisy forces and joint positions, as a probability.
If you have followed the Physical AI lessons, State, observation, belief introduces the same three words without mathematics. This course supplies the mathematics.
Common misconceptions
“A probabilistic robot behaves randomly.”
The robot's software is deterministic: the same data produce the same belief and the same action. Probability describes what the robot knows about a world it cannot observe exactly. It is bookkeeping for doubt, not dice in the controller.
“With good enough sensors you do not need probability.”
Better sensors shrink the uncertainty; they do not remove it, and they do nothing about slip, moving people or a wrong map. Even a centimetre-accurate lidar leaves a robot that must decide how much to trust it against its wheel odometry, which is a probability question.
“Uncertainty is the same thing as error.”
The error is the one unknown number by which this estimate is off. The uncertainty is the known description of how large errors tend to be. A filter can report its uncertainty exactly while its error stays unknown; a filter whose errors are regularly larger than its reported uncertainty is called overconfident, and module 7 shows how to detect it.
“A probability of 0.9 means the statement is 90% true.”
The door is either within stopping distance or it is not. The 0.9 measures the strength of the evidence, and its practical meaning is in the long run: of all the situations in which a well-calibrated robot says 0.9, the statement is true in about nine out of ten.
Key takeaways
- Uncertainty enters a robot through actuation, sensing, the environment, the model and the computation. It can be reduced but not removed.
- A probability can be read as a long-run frequency (a property of the robot and its world) or as a degree of belief (a property of what the robot knows). Both follow the same rules.
- The state is the truth, the estimate is a best guess, the error is their unknown difference, and the uncertainty describes which errors are plausible.
- A belief assigns a probability to every possible state, given all the data so far. It is the quantity every filter in this course computes.
- Good decisions weigh each possible outcome by its probability and its cost. The most likely state alone can recommend an action that is, on average, much worse.
References and further reading
Each source is marked free or paid. Free to read does not mean free to reuse: the course resources page lists every source with its licence.
- S. Thrun, W. Burgard and D. Fox, Probabilistic Robotics, MIT Press, 2005, chapter 1 (Introduction) and section 2.1. The standard textbook for this course. Paid book.
- C. Stachniss, “Probability Primer for Probabilistic Robotics” (video lecture) . Free to watch.
- T. D. Barfoot, State Estimation for Robotics, 2nd edition, Cambridge University Press, 2024 , chapter 1. Free to read as the author's PDF; the book is copyrighted.
- J. Tsitsiklis and P. Jaillet, MIT RES.6-012 Introduction to Probability , lecture 1. Free videos and notes, licence CC BY-NC-SA 4.0.
- ROS 2 geometry_msgs/PoseWithCovariance message definition . Free documentation.
Knowledge check
Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
Rover's wheel encoders report 2.00 m after a drive, and a tape measure shows 1.94 m. A teammate says “the uncertainty of the odometry is 6 cm”. What is wrong with that sentence, and what would you need in order to state the uncertainty?
Explanation
The 6 cm is the error of this one run, a single number that happened to be measurable because someone used a tape. The uncertainty describes how errors are distributed over many runs. To state it you need repeated runs (or a model of the slip) and a summary of the spread of their errors, for example a standard deviation. One run with a 6 cm error is compatible with an uncertainty of 3 cm or of 10 cm.
Question 2
A warehouse robot believes there is a 5% probability that a person is behind a shelf corner. Stopping to check costs 4 seconds; a collision is judged 1000 times worse. Should it stop? What is the largest probability at which it may drive on?
Explanation
Stop. The threshold is p* = Cs / Cc = 1/1000 = 0.001. The belief of 0.05 is fifty times above it: the expected cost of driving on is 0.05 × 1000 = 50 units against 1 unit for stopping. The robot may drive on only when its belief is below 0.1%, which in practice means it needs evidence (a mirror, a second sensor, a slower approach that lets it see around the corner), not a more optimistic guess.
Question 3
Give one example of noise and one of ignorance in a drone hovering indoors, and say which of the two more flight time can reduce.
Explanation
Noise: the scatter of successive barometer or range-finder readings around the true height, or the vibration seen by the accelerometer; it is still there after an hour of flight. Ignorance: the accelerometer bias, the exact position where the drone took off, or the height of the ceiling; each is a fixed unknown that measurements gradually pin down. More flight time (more data) reduces ignorance. It only lets the estimator average the noise, which never disappears.
What’s next
You now have the vocabulary. The next lesson gives the three rules that every probability, frequency or belief, must obey.
Related content
Nothing below is required to finish this lesson.
- LabM1-L1: Noisy Robot Motion Simulator
The same command gives a different end position every run. Simulate noisy motion, measure the spread, and predict how often the robot stops inside the docking zone.
Other courses on this site treat neighbouring topics from their own angle:
Get notified when the next lesson and new labs are released.
One email per new lesson or lab.