Glucose Sensor Lab

2D companion of the CGM drift simulator: blood, interstitial fluid and sensor on one strip chart.

Switch to 3D

Presets

Playback

Apparatus

Model checks

The science

What is modelled

A continuous glucose monitor does not touch blood. Its filament sits in the fluid between cells, and glucose reaches it by diffusion across the capillary wall, which takes some minutes. On top of that the sensor slowly loses sensitivity, its zero drifts and its signal is noisy. A fingerstick calibration rescales the reading.

Equations

  • Interstitial lag dI/dt = (G − I) / τ, solved exactly for piecewise-linear G.
  • Sine response amplitude = 1 / √(1 + (ωτ)2), delay = arctan(ωτ).
  • Sensor S = I (1 − g d) + b d + noise with d the days worn.
  • One-point calibration Scal = S · Gref / Sref at each fingerstick.
  • Mean absolute relative difference MARD = mean(|S − G| / G).

Checks run in the page

  • The exact lag update against an independent fine Euler integration.
  • Amplitude and delay of the lag for a 60 min sine against the formula.
  • The area identity of a first-order lag.
  • The noise-free gain after 72 h against the drift law.

Honest simplifications

The glucose curve is a smooth made-up day with three meals and one dip, not a patient record. A single lag constant, linear drift, white noise and one-point calibration with perfect fingersticks are used. Calibrating during a fast rise bakes the lag into the gain, which the chart shows.

What to try
  • Press Perfect sensor: only the lag error remains.
  • Press Drifting, never calibrated and then Calibrate every 4 h to see the error reset.
  • Raise the lag and watch the zoom plot: the interstitial curve peaks later and lower.
Three-day traces
Meal zoom: blood against interstitial
Mean error per day
Frequency response of the lag