Probability for Robotics · Theory · M2
M2-T3 — The Gaussian Distribution
Two numbers describe a Gaussian: where it is centred and how far a typical error reaches. Nearly every sensor model in robotics is built from them.
If you remember one distribution from this course, make it the Gaussian. Range readings, encoder drift, IMU noise and position estimates are all modelled with it, and the Kalman filter works because it is the one distribution whose shape survives addition, scaling and multiplication. This lesson explains what its two parameters mean physically, what the 68-95-99.7 rule tells you about a sensor, why errors end up bell-shaped, and where the bell is a poor model.
Learning objectives
After this lesson, you should be able to:
- Read the mean and standard deviation of a Gaussian as a centre and a typical error, and sketch the curve from them.
- Use the 68-95-99.7 rule, z-scores and the standard normal table (or gaussian_cdf) to compute probabilities and tolerances.
- Derive the Gaussian normalization constant and the Gaussian shape from independence and rotational symmetry.
- Explain why the sum of many small independent errors is nearly Gaussian, and name three situations where a Gaussian is a poor model.
The intuition
Repeat the same measurement many times and plot the results. The values bunch around a centre, thin out symmetrically on both sides, and almost never lie far away. The smooth curve that describes this is the Gaussian, or normal, distribution. Two numbers are enough to draw it.
- The mean is the centre: where the curve peaks. A sensor whose mean error is not zero has a bias: it is wrong in the same direction every time.
- The standard deviation is the width: the typical distance of a reading from the centre. It has the unit of the measurement, so a range sensor has a in centimetres. A smaller gives a taller, narrower curve; the area is always 1.
The right-hand panel is the most useful fact in this lesson. It lets you read a sensor's data sheet. If a range sensor has cm, then about two readings in three are within 2 cm of the truth, about 19 in 20 are within 4 cm, and a reading more than 6 cm off is a one-in-370 event. Note the wording: typical distance does not mean maximum distance.
Why a bell?
The bell shape is not an arbitrary choice. Most measurement errors are made of many tiny, independent causes: thermal noise in an electronic component, small vibrations, rounding, slight air turbulence, the jitter of a clock. Each contributes a little, in a random direction, and the total is their sum. The figure below shows what happens when you add independent errors that are individually not bell-shaped at all. One uniform error is flat. The sum of two is a triangle. The sum of three is already rounded, and the sum of twelve lies almost on top of the Gaussian curve.
That behaviour is the central limit theorem: the sum of many independent small errors is approximately Gaussian, whatever the shape of the individual errors. It explains why the Gaussian is a good default, and the conditions in its statement (many, small, independent) tell you when to distrust it.
There is a second reason, a practical one. The Gaussian is the one distribution family for which the operations of a filter keep the answer inside the family. Add two independent Gaussian errors and the total is Gaussian. Multiply a Gaussian error by a constant and it is still Gaussian. Fuse two Gaussian beliefs about the same thing and the result is Gaussian. Because of this, a belief can be stored as two numbers, a mean and a variance, instead of a whole curve, and that is the Kalman filter (module 7).
Remember the three numbers 68, 95 and 99.7, with 1, 2 and 3 standard deviations. They turn a standard deviation on a data sheet into a statement about how often a reading is wrong by how much.
Definitions
- Gaussian
- The distribution with mean and variance . We write for “ is Gaussian with these parameters”. The second argument is the variance, the square of the standard deviation; some software expects the standard deviation instead, a classic source of errors.
- Mean
- The centre of the curve and its long-run average.
- Standard deviation
- The width: the typical distance from the centre. Same unit as .
- Variance
- The square of the standard deviation. Unit: the unit of squared. Variances add for independent errors; standard deviations do not.
- Standard normal
- The Gaussian with and . Its cumulative distribution is written .
- z-score
- : how many standard deviations lies from the centre. A z-score is a pure number and does not depend on the unit.
| k | Outside, one in about | Comment | |
|---|---|---|---|
| 1 | 0.6827 | 3 | a typical error |
| 1.96 | 0.9500 | 20 | the usual 95% interval |
| 2 | 0.9545 | 22 | |
| 2.576 | 0.9900 | 100 | the usual 99% interval |
| 3 | 0.9973 | 370 | the “three-sigma” rule |
| 4 | 0.99994 | 15 800 | a rare event, but see the beam example below |
Properties used constantly
| Operation | Result | Meaning |
|---|---|---|
| Shift and scale: | The centre moves like any value; the standard deviation scales by , the variance by . | |
| Sum of independent: | Variances add. The standard deviations add in quadrature: . Two errors of 3 cm and 4 cm combine to 5 cm, not 7 cm. | |
| Average of independent copies | Standard deviation : the reason averaging helps, and the reason for the square-root law of the Monte Carlo lesson. | |
| Product of two Gaussian densities of the same variable | proportional to a Gaussian | The heart of the Kalman filter: a Gaussian belief times a Gaussian likelihood is a Gaussian (module 4). |
The proofs of the sum rule and of the product rule are in M4-T1: Expectation and Variance and M4-T5: Conditioning and Fusing Gaussians.
Derivation: where the constant and the bell come from
Why the factor
The area under must be computed so that the density integrates to 1. There is no antiderivative in elementary functions, but the area itself has a classical closed form, found by squaring it and changing to polar coordinates.
Square the integral and write it as a double integral over the whole plane, using a different name for the second variable.
Switch to polar coordinates: and the area element is . The extra factor is what makes the integral doable.
The inner integral has the antiderivative . The angle integral is just .
Divide by to normalize the standard normal. With the unit-change rule of the last lesson, gives the density , the formula above.
Why the bell: no preferred direction
Rover drops a part on a table at a target point. The landing error has a horizontal part and a vertical part . Make two assumptions that are easy to state physically, and the Gaussian is the only answer.
The two components are independent and have the same shape (the robot is no better at one axis than the other).
There is no preferred direction: the density depends only on the distance from the target, for some function . A rotated table gives the same statistics.
Put to get , substitute that back into the first line to eliminate , divide by and take logarithms.
A function whose value at a sum is the sum of its values. For a continuous function this forces for a constant (the only continuous solutions are straight lines through the origin; the sign is negative so that the area is finite).
Undo the substitutions: . This is a Gaussian with , and normalization fixes .
A two-dimensional error cloud with independent axes and no preferred direction must be Gaussian. That is why the round, symmetric cloud of position errors in the Kalman filter is a Gaussian, and why a cloud that is stretched along a particular direction needs a covariance matrix (module 4) instead of a single σ.
A worked example
A range sensor has a Gaussian error with and cm. Five questions about it, all answered by the program below.
- Tolerance. How often is a reading within ±3 cm of the truth? , so : about 87%.
- Specification. A new application needs 99% of the readings within ±5 cm. For 99% two-sided the z-score is 2.576, so cm. The sensor must be slightly better than the one we have.
- Averaging. The mean of 16 independent readings has cm. The probability that this average is within ±1 cm is , so 0.9545. (The 16 readings must be independent; the correlation warning of the binomial lesson applies again.)
- The bell from nothing. Add 12 independent uniform numbers on . Each has variance , so the sum has variance 1 and standard deviation 1. Simulating 20 000 such sums gives mean −0.002, standard deviation 0.999, and shares within 1, 2 and 3 of 0.6807, 0.9553 and 0.9978, against the Gaussian's 0.6827, 0.9545 and 0.9973.
- Three sigma is routine. A scanning lidar delivers 1000 beams at 10 Hz, 10 000 readings a second. A fraction 0.0027 lies beyond 3σ even when nothing is wrong: 27 beams every second. Beyond 4σ it is still 0.63 beams a second. “More than three standard deviations” is therefore a poor definition of a faulty reading on its own.
from robotprob import Rng, gaussian_cdf, gaussian_ppf, mean, std
sigma = 0.02 # 2 cm, in metres
print('P(|e| <= 3 cm) =', round(gaussian_cdf(0.03, 0.0, sigma) - gaussian_cdf(-0.03, 0.0, sigma), 4))
z = gaussian_ppf(0.995) # 99% two-sided leaves 0.5% in each tail
print('z for 99% two-sided =', round(z, 3), ' sigma needed =', round(5 / z, 2), 'cm')
n = 16
s_mean = sigma / n ** 0.5 # the average of n independent readings
print('sigma of the mean of', n, ' =', s_mean)
print('P(|mean error| <= 1 cm) =', round(gaussian_cdf(0.01, 0.0, s_mean) - gaussian_cdf(-0.01, 0.0, s_mean), 4))
rng = Rng(11) # a sum of 12 uniform numbers is almost Gaussian
s = [sum(rng.uniform(-0.5, 0.5) for _ in range(12)) for _ in range(20000)]
print('sum of 12 uniforms: mean', round(mean(s), 3), 'std', round(std(s), 3))
for k in (1, 2, 3):
print('within', k, 'sigma:', round(sum(1 for v in s if abs(v) <= k) / len(s), 4), ' Gaussian:', round(gaussian_cdf(k) - gaussian_cdf(-k), 4))
rate = 1000 * 10 # beams per second
for k in (3, 4):
q = 2 * (1 - gaussian_cdf(k))
print(k, 'sigma: fraction', round(q, 6), '->', round(q * rate, 2), 'beams per second')P(|e| <= 3 cm) = 0.8664 z for 99% two-sided = 2.576 sigma needed = 1.94 cm sigma of the mean of 16 = 0.005 P(|mean error| <= 1 cm) = 0.9545 sum of 12 uniforms: mean -0.002 std 0.999 within 1 sigma: 0.6807 Gaussian: 0.6827 within 2 sigma: 0.9553 Gaussian: 0.9545 within 3 sigma: 0.9978 Gaussian: 0.9973 3 sigma: fraction 0.0027 -> 27.0 beams per second 4 sigma: fraction 6.3e-05 -> 0.63 beams per second
gaussian_cdf(x, mu, sigma) and gaussian_ppf(p) are the cumulative distribution and its inverse. The second argument of the lesson’s notation is a variance; the library, like most, takes the standard deviation.In robotics
Reading a data sheet
Data sheets quote noise in several ways, and the first job is to find out which. “Accuracy ±3 cm” may be a guaranteed bound, a 1σ value or a 95% interval. “Noise density 0.01 °/s/√Hz” for a gyroscope means a standard deviation that grows with the measurement bandwidth. Converting to a common σ before combining sensors is basic hygiene; the UAV course shows it for inertial sensors in IMU noise and bias modelling.
Combining independent errors
A ground robot's position error at the end of a corridor is the sum of a heading error and a distance error. Each is a Gaussian, so their combination is another, with variance equal to the sum. Square, add, and take the root: this is how an error budget is computed. Errors of 3 cm, 4 cm and 12 cm give 13 cm, and shrinking the smallest ones barely helps: improve the biggest first.
Setting thresholds and gates
A fixed threshold on a measurement residual, “reject if the difference between measured and predicted range exceeds 3σ”, is the Gaussian rule in practice. The Kalman filter gates with the Mahalanobis distance, the multi-dimensional version of the z-score (M4-T3: The Multivariate Gaussian and Covariance Ellipses, M8-T2: EKF Localization with Landmarks). As the beam example showed, a 3σ gate rejects 0.27% of perfectly good measurements; whether that is acceptable is an engineering decision.
Where a Gaussian is a poor model
- Heavy tails and outliers. A lidar beam that hits a person walking through the scan, a GPS multipath jump or a camera mismatch produces errors far beyond any Gaussian tail. Real sensor error is often a Gaussian core plus a small share of outliers; the next lesson models this.
- Bounded quantities. A range cannot be negative and a battery level cannot exceed 100%. A Gaussian puts a little probability on impossible values; when the mean is many σ from the boundary the effect is negligible, and when it is not (a sensor reading near zero range) it matters.
- Several modes. A robot in a corridor with three identical doors has a belief with three peaks. A single Gaussian cannot represent it, which is why module 6 begins with the histogram filter and module 9 with particles.
- Angles. A heading is on a circle, so a Gaussian on the real line is wrong near ±180°. Module 12 treats uncertainty on angles properly.
The SLAM and Perception courses use the same normal distribution; the SLAM view of it is in Probability and Uncertainty.
Common misconceptions
“A standard deviation of 2 cm means readings are never more than 2 cm off.”
It is the typical distance, not a bound. A third of the readings are further than one standard deviation away, and one in 22 is further than two. Specify a maximum error with a probability attached: “99% within ±5 cm”.
“Two errors of 3 cm and 4 cm add up to 7 cm.”
Only if they are perfectly aligned. Independent errors add in quadrature: the combined standard deviation is √(3² + 4²) = 5 cm. The variances add, the standard deviations do not. For the average of n independent readings the error falls as 1/√n.
“Everything is Gaussian.”
The central limit theorem needs many independent, small contributions of finite spread. A bumper that is either pressed or not, an outlier from a reflective surface, a quantized count and an angle are not Gaussian. A filter that assumes it anyway is overconfident exactly when the data are strangest.
“N(0, 2) has a standard deviation of 2.”
In the usual notation the second argument is the variance, so that Gaussian has σ = √2 = 1.41. Software differs: some libraries take σ and some take σ². Check the documentation, and test with a case whose spread you know, before trusting a simulated noise level.
Key takeaways
- A Gaussian is fixed by its mean (the centre, the place a bias moves) and its standard deviation (a typical error, in the unit of the measurement).
- About 68% of values lie within 1σ, 95% within 2σ (1.96 for exactly 95%) and 99.7% within 3σ. A z-score counts standard deviations and has no unit.
- Independent Gaussian errors add in variance, so standard deviations combine in quadrature. The average of n independent readings has standard deviation σ/√n.
- Sums of many small independent errors are nearly Gaussian (the central limit theorem). A symmetric, independent two-dimensional error cloud must be Gaussian.
- The Gaussian is a model. It fails for outliers, bounded quantities, several modes and angles, and 3σ readings are routine when there are thousands of readings a second.
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.
- J. Tsitsiklis and P. Jaillet, MIT RES.6-012 Introduction to Probability , lectures 8 to 10 (continuous random variables, including the normal) and lecture 19 (the central limit theorem). Free videos and notes, licence CC BY-NC-SA 4.0.
- J. Blitzstein and J. Hwang, Introduction to Probability, 2nd edition, CRC Press, 2019 , chapters 5 and 10. Free to read online; the book is copyrighted.
- J. F. W. Herschel, review of Quetelet’s Letters on the Theory of Probabilities, Edinburgh Review, 1850, and J. C. Maxwell, “Illustrations of the dynamical theory of gases”, Philosophical Magazine, 1860: the two original symmetry arguments for the Gaussian. Paid journal articles.
- C. Stachniss, “Probability Primer for Probabilistic Robotics” (video lecture) . Free to watch.
- S. Thrun, W. Burgard and D. Fox, Probabilistic Robotics, MIT Press, 2005, section 2.2 (the normal distribution) and chapter 3. Paid book.
Knowledge check
Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.
Question 1
A depth camera’s datasheet says “depth noise 1.5 cm at 3 m (1σ)”. Estimate the probability that a single reading is wrong by more than 3 cm, and the number of independent readings you would average to bring the typical error to 0.5 cm.
Explanation
A 3 cm error is 2σ, so the probability of being off by more than that in either direction is about 1 − 0.9545 = 4.6%. Averaging n independent readings gives σ/√n, so 1.5/√n = 0.5 requires √n = 3 and n = 9 readings. This assumes the errors are independent between readings; for a camera, part of the noise is a fixed pattern (bias) that is the same every frame and does not average away, so the true improvement is smaller and a calibration is also needed.
Question 2
A robot’s position error after a straight run has two independent Gaussian contributions: a 4 cm error from wheel slip and a 3 cm error from the start position. What is the standard deviation of the total, and why is it not 7 cm? What if the two errors were perfectly correlated?
Explanation
The total standard deviation is √(4² + 3²) = 5 cm, because variances of independent errors add (16 + 9 = 25 cm²) and the standard deviation is the square root. A sum of 7 cm would require the two errors to always have the same sign and size, which independent errors do not. If they were perfectly correlated (one always equal to the other, scaled), the standard deviations would add and the total would be 7 cm. Correlation changes the combination rule, which is why module 4 introduces covariance.
Question 3
Why is a Gaussian a poor model for the error of a range sensor that sometimes returns the distance to a wall behind a window, and what does that do to a filter that assumes a Gaussian?
Explanation
The window produces a wrong reading that is not a small perturbation of the truth but a different quantity entirely, many metres off, with some probability. The error distribution is a narrow Gaussian core plus a rare far-away component, so its tails are far heavier than a Gaussian’s. A filter that assumes a Gaussian assigns that reading an almost-zero likelihood, or, if it does not gate, lets it pull the estimate by an amount proportional to its enormous error, because a Gaussian model treats a huge residual as overwhelming evidence. Remedies are gating on the Mahalanobis distance, a mixture model with an explicit outlier component, or a robust loss.
What’s next
A real sensor is rarely a clean Gaussian. The next lesson separates what is in a typical sensor’s error (bias, noise, quantization and outliers) and builds models for each.
Related content
Nothing below is required to finish this lesson.
- BeforeM2-T2: Continuous Random Variables, Densities and the CDF
Explain why a density is not a probability, and compute probabilities of intervals from a density or a cumulative distribution.
- LabM2-L1: Sensor Noise Explorer
A range sensor reads a wall at a fixed distance and the readings scatter. Build the histogram, estimate bias and spread, and find the outliers a Gaussian cannot explain.
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.