Concept 01: Sensor Noise & Normal Distributions

▶ Interactive Demo: Sensor Noise & Bell Curve Visualizer

Open the interactive demo below to adjust the true distance μ (mean) and sensor noise σ (standard deviation) sliders, generate 1,000 live sensor readings, and watch the histogram match the theoretical Gaussian bell curve.


1. The Real-World Problem: The Jittery Sensor

Suppose an autonomous robot uses an optical distance sensor or an AprilTag camera to measure its distance from the field reef wall.

Even if the robot is parked completely still at a true distance of 4.00 meters, 10 consecutive sensor readings might look like this:

[3.98, 4.04, 3.95, 4.01, 4.02, 3.97, 4.05, 3.99, 4.00, 3.99]
Mean μ = 4.00m ±1σ (68%)

Why do sensors jitter? Thermal vibrations inside electronics, photon shot noise in cameras, and minor electrical voltage fluctuations all add tiny, random errors.

How do we model this uncertainty mathematically so our robot can trust its sensors safely?


2. Solving It in Code (Java & WPILib)

First-Principles Java: Simulating Sensor Gaussian Noise

import java.util.Random;

Random rng = new Random();
double trueDistance = 5.00; // 5 meters
double sensorNoiseSigma = 0.08; // 8 cm standard deviation (±0.08 m)

for (int i = 0; i < 5; i++) {
    // nextGaussian() generates numbers from N(0, 1)
    double noisyReading = trueDistance + rng.nextGaussian() * sensorNoiseSigma;
    System.out.printf("Sample %d: %.3f meters%n", i + 1, noisyReading);
}

3. Bridge to Machine Learning: Diffusion Models & Weight Initialization

In modern generative AI:


4. Review Checkpoints

Checkpoint 1

A LiDAR sensor has mean μ = 3.0m and noise σ = 0.05m. Between what two distances will 95% of all sensor readings fall?

Solution: Using the ±2σ rule: [μ - 2σ, μ + 2σ] = [3.0 - 2(0.05), 3.0 + 2(0.05)] = [2.90m, 3.10m].


Checkpoint 2

Sensor A has standard deviation σ = 0.02m. Sensor B has σ = 0.10m. Which sensor is more precise, and why?

Solution: Sensor A is much more precise because its spread (0.02m) is 5× smaller than Sensor B’s (0.10m). Its bell curve is tall and narrow.


← Concept 15: Gradients & Optimization
Module 5 Overview
Concept 17: Bayes' Rule & Sensor Fusion →