Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Calibration drift: compare sensor readings with a reference

Last updated: 5 Oct 20265 min read
tutorial
IntermediateBy AITrove Editorial

A sensor can be precise from reading to reading while remaining systematically wrong against a trusted comparison.

Pair readings at the same condition

A warehouse temperature logger is checked against a reference probe. Each pair needs the same place, time and stable condition; comparing readings taken 20 minutes apart during a door opening confounds device error with real temperature change. Store sensor ID, reference ID, calibration dates, operating range and the paired values. The signed error is sensor minus reference. A frozen snapshot keeps the reference and sensor versions together.

Separate bias and scatter

For each sensor, report mean signed error, spread of paired differences and the maximum absolute deviation across the checked range. A mean near zero can hide positive error at warm temperatures and negative error at cold temperatures, so inspect error by reference range. Repeat checks after repair, relocation or a firmware change. A single offset correction is unjustified if the response curve bends or if error depends on humidity.

Look for drift over time

A device can pass a check in January and wander by July. Plot paired error against check date for that device, with maintenance events marked. Do not infer a smooth drift line from two points without acknowledging its uncertainty. If data between checks need correction, retain raw readings and create a versioned corrected series with an explicit validity period. Historical joins help select the correction version valid at the measurement time.

Treat a failed check as a data decision

If reference comparisons breach the agreed tolerance, identify affected shipments and time ranges. Quarantine uncertain measurements or flag them for sensitivity analysis; do not silently delete them. Confirm whether the reference device was itself in date and appropriate for the range. Outlier triage separates a bad device value from a genuine temperature excursion.

Use a concrete audit

Suppose a sensor reports 7.4, 8.1 and 8.8 degrees while paired reference readings are 7.1, 7.8 and 8.5. Each signed error is +0.3 degree, so an additive offset is plausible over those three points. That is evidence only over the tested range and conditions; a corrective rule still needs review and future checks.

Implementation

python
from statistics import mean

def paired_sensor_bias(paired_readings):
    if not paired_readings:
        raise ValueError("reference pairs required")
    differences = [sensor_c - reference_c
                   for sensor_c, reference_c in paired_readings]
    return {"mean_signed_error": mean(differences),
            "maximum_absolute_error": max(abs(error) for error in differences)}

result = paired_sensor_bias([(7.4, 7.1), (8.1, 7.8), (8.8, 8.5)])
assert round(result["mean_signed_error"], 2) == 0.3

Performance and operating cost

For N paired checks, mean and maximum-error calculation cost O(N) time; this implementation stores O(N) differences for clarity, but a streaming accumulator can use O(1) memory. Range-specific or time-varying calibration needs more observations and a versioned model.

Common Mistakes

  • Do not interpret repeatable readings as accurate without a reference check.
  • Do not fit one offset from a narrow range and apply it everywhere.
  • Do not overwrite raw measurements when applying a later correction.

Read next

ai-data
data-science
Storage details