TactivergeLite

Lite / Intelligent Robotic Systems / Week 20

Mean, spread and the histogram

Ten readings of the same distance never match. Which single number should the robot believe, and how much should it trust it?

About 35 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

A single reading hides its own uncertainty. Repeating it and summarising the results with a mean and a standard deviation tells you both the best estimate and how much it wobbles: the two numbers every honest measurement report needs.

Predict

A sensor with noise σ = 4 gives 64 readings. Roughly how wide is the middle two-thirds of the histogram?

  1. About 1 unit
  2. About 8 units (σ either side of the mean)
  3. About 64 units
Guess first, then reveal

For bell-shaped noise, about 68% of readings fall within one standard deviation of the mean, so the middle two-thirds spans about 2σ = 8 units. Taking more readings fills the histogram in; it does not make it narrower.

Discover

Stay on 'One batch'. Take 64 readings with σ = 4 and look at the histogram's shape. Compare the sample standard deviation with σ. Now try n = 4 several times with new data: how much does the estimate of σ itself jump around?

What the interactive shows (text version)

The diagram draws a histogram of readings from a sensor with adjustable noise σ and bias. With n = 64 and σ = 4, the bars form a hump centred near the true value plus bias, about 16 units wide in total; the readout lists the readings, the mean and the sample standard deviation, which comes out close to 4.

You can also open the interactive on the full site when you have a faster connection.

Understand

The mean: best single estimate

The mean x̄ = (x₁ + x₂ + … + xₙ) ÷ n. When errors are random and unbiased, it is the best single guess of the true value. It is sensitive to outliers: one glitch reading of 9999 drags it badly, which is why spikes are often removed first.

Standard deviation: typical distance

The sample standard deviation s = √(Σ(xᵢ − x̄)² ÷ (n − 1)) measures how far readings typically sit from their mean. Same units as the readings. For bell-shaped (normal) noise, about 68% of readings fall within ±s of the mean and about 95% within ±2s.

Why n − 1?

The deviations are measured from x̄, which was computed from the same readings, so they come out a little smaller than deviations from the true value would. Dividing by n − 1 instead of n corrects that on average. With 3 readings it matters a lot; with 300 it barely matters.

Histograms show the shape

A histogram counts readings in equal bins. A single tall, symmetric hump suggests random noise. Two humps suggest two different conditions mixed together; a long tail on one side suggests occasional glitches. Always look before you average.

Explain it another way

Intuitive

The mean is the balance point of the readings on a seesaw. The standard deviation is how far, typically, each reading sits from that balance point.

Technical

x̄ = Σxᵢ/n, s² = Σ(xᵢ − x̄)²/(n − 1). For independent normal noise of standard deviation σ, s is an estimate of σ whose own uncertainty is roughly σ/√(2(n − 1)).

Mathematical

Σ(xᵢ − x̄)² = Σ(xᵢ − μ)² − n(x̄ − μ)². Its expected value is nσ² − σ² = (n − 1)σ², so dividing by n − 1 gives an unbiased estimate of σ².

Applied

Datasheets often quote noise as an RMS value (a standard deviation) and sometimes as peak-to-peak, which is several times larger for the same sensor. Know which you are reading before comparing two sensors.

Worked example 1

Readings: 10.2, 9.8, 10.4, 9.6, 10.0 cm. Find x̄ and s.

x̄ = 50.0 ÷ 5 = 10.0 cm. Deviations: 0.2, −0.2, 0.4, −0.4, 0. Squares add to 0.04 + 0.04 + 0.16 + 0.16 + 0 = 0.40. s = √(0.40 ÷ 4) = √0.10 ≈ 0.32 cm.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

V

cm

cm

Practice 4. Noise is bell-shaped with mean 50 and s = 2. About what share of readings lie between 46 and 54?
Practice 5. A histogram of a robot's distance readings has two separate humps. What should you suspect first?

Apply it

Write a Python function summary(readings) that returns the mean, sample standard deviation and the share of readings within ±2s. Test it on the readings from the diagram with n = 64, and compare the share with 95%.

Reflect

Why should a measurement report give a spread, not just a mean?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Random and systematic errorThe standard error: how sure is the average? →