# Inertial Error Integration

This demo makes the inertial error-integration chain concrete. An error process is injected at one end of the chain (acceleration or velocity) and integrated forward to see how it shows up as a navigation error. The error process is selectable from the four canonical models:

1. **Constant bias** — a deterministic offset, e.g. an uncalibrated accelerometer null.
2. **White noise** — uncorrelated samples each step, the model for sensor measurement noise.
3. **Random walk** — the error itself wanders; its variance grows linearly with time. The natural model for many gyro biases.
4. **Gauss-Markov** — mean-reverting noise with a finite memory τ. It bridges white noise (τ → 0) and random walk (τ → ∞), and it is the standard model for accelerometer biases that have no preferred value but do have a finite correlation time.

The teaching point is that the **further "upstream" the sensor error sits in the integration chain, the higher the time-order of the resulting position error**. A constant velocity bias gives linear position growth; a constant acceleration bias gives quadratic position growth. White noise integrates into a random walk ($\sigma \propto \sqrt{t}$); random walk integrates into something faster yet ($\sigma \propto t^{3/2}$). Gauss-Markov sits between the two depending on τ.

## Interactive demo

<a class="demo-fullscreen" href="../_static/demos/ErrorIntegrationDemo.html" target="_blank" rel="noopener">Open in full screen</a>

<div class="demo-wrap">
<iframe src="../_static/demos/ErrorIntegrationDemo.html"
        title="Interactive inertial error integration demo"
        width="100%"
        loading="lazy">
</iframe>
</div>

## Walkthrough

The demo opens on **white noise injected at the acceleration level** with $\sigma = 0.01$ m/s². The single dark trace is one realization; the lighter shaded band is the empirical $(1-\alpha)$ envelope from a 30-realization ensemble. Try the following:

1. **Switch to "Constant bias"** and stay at acceleration injection. Drag the bias slider — the velocity panel grows linearly and the position panel grows quadratically. With $b = 0.02$ m/s² and $T = 600$ s, the position error reaches $\tfrac{1}{2} b T^2 = 3600$ m. This is the worked example from the Block 2 reading.
2. **Switch the injection point to "velocity"** (still constant bias). Now the acceleration panel is empty and the position panel grows linearly at rate $b$ — one fewer integration than the acceleration case, one fewer power of $t$.
3. **Switch to "White noise" + acceleration.** Toggle "show ensemble" on. The 30 light realizations show the spread; the dark band is the $(1-\alpha)$ empirical bound from those realizations. Move the α slider — the band scales by $k = \sqrt{2}\,\text{erfinv}(1-\alpha)$. Click "95%" — band widens to $\pm 1.96\sigma$.
4. **Switch to "Random walk" at acceleration.** The acceleration trace itself wanders (variance grows as $q^2 t$). The integrated panels grow much faster than the white-noise case at matched amplitude — position $\sigma \propto t^{5/2}$.
5. **Switch to "Gauss-Markov".** Slide $\tau$ from short ($\tau \approx \Delta t$) to long ($\tau \to T$). Short $\tau$: looks like white noise (variance is bounded by $\sigma_{ss}^2$). Long $\tau$: looks like a slow random walk over the run length. **This is the bridge model the Block 2 reading talks about.**
6. **Open the cheat sheet** at the bottom of the demo to see the closed-form variance growth for each model and integration depth. The metrics row shows the empirical $k\sigma$ from the 30-run ensemble alongside the theoretical $k\sigma$ from those formulas — they should agree closely when the simulation is long enough for the ensemble to converge.

## Key observations

- **Integration order matters more than amplitude.** A 0.02 m/s² accel bias is sneakier than a 0.1 m/s velocity bias even though the latter sounds bigger, because the former hits position with two integrations instead of one.
- **Confidence interval ≠ accuracy.** A tight band around a single realization tells you about ensemble spread, not whether the realization is biased. Re-seed a few times to confirm individual realizations move while the band stays put.
- **Random walk is qualitatively different from white noise integrated.** White-noise velocity integrates into a position random walk ($\sigma \propto \sqrt{t}$). A random-walk velocity, on the other hand, has variance that itself grows linearly, and its integral grows like $t^{3/2}$. That extra factor of $t$ is what makes random walk so painful for inertial systems running open-loop.
- **Gauss-Markov saturates.** Unlike random walk, the Gauss-Markov error stays bounded around its steady-state $\sigma_{ss}$. Its integrated descendants still grow with time, but the source of growth is the *integral of a bounded process*, not an unbounded one. That's why most accelerometer specs use Gauss-Markov for bias modeling instead of pure random walk.

## Source

<a class="matlab-link" href="../_static/downloads/SY6301%20Navigation%20and%20State%20Estimation%20%E2%80%93%20Code.zip#code/ErrorIntegrationDemo.m" download><svg viewBox="0 0 22 22" width="14" height="14" aria-hidden="true" style="vertical-align:-2px;margin-right:6px;"><rect width="22" height="22" rx="3" fill="#e87722"/><text x="11" y="15.5" text-anchor="middle" font-family="'Inter',sans-serif" font-size="9" font-weight="800" fill="#fff" letter-spacing="-0.04em">MAT</text></svg><span class="ml-text">MATLAB · code/ErrorIntegrationDemo.m</span><span class="ml-arrow">↓</span></a>
