ELAI S.r.l.

AI flags more anomalies: what if the sensor changed?

Before retraining AI, separate real changes from measurement errors: a complete calibration example, separate checks and limitations using synthetic data.

AI flags more anomalies: what if the sensor changed?

Before changing AI, check what it is measuring

A system reports that a room is warmer than usual. The manager sees more alerts and considers retraining the model. But the change might be in the room, the sensor or the software converting its reading. How can we distinguish causes before working on the wrong problem? We develop a complete numerical example to understand when checking the sensor precedes updating AI and what information supports that decision.

The case is entirely synthetic: temperatures and reference values are author-chosen numbers, not instrument readings. No microcontroller, sensor, AI model or alarm system was tested. Executed code estimates a simple reference-to-reading relationship, inverts it and checks four separate values. It is neither a certification procedure nor evidence of device performance. Every result retains this distinction between calculation and measurement.

One reading cannot identify its cause

Suppose we read 22 °C. In world A the temperature is 20 °C and the instrument adds a constant 2 °C error. In world B the temperature really is 22 °C and the instrument adds nothing. The observed number is identical. An algorithm receiving that number alone cannot distinguish these worlds without additional assumptions or information. This is not a training defect: it is missing information, called non-identifiability of the cause.

observed = true_value + offset 22 = 20 + 2 = 22 + 0

An independent reference can break the ambiguity. It must measure the same quantity under the same relevant conditions: probes in different positions can read different temperatures without either being faulty. Timing, location and stabilization belong to the comparison. Independent does not mean infallible: the reference has uncertainty and may share errors with the instrument. Our ideal calculation assumes reference values known to isolate the mechanism, not because such perfection exists in a plant.

Two different ways to be wrong

A sensor may add the same offset or amplify changes. To distinguish them, use a line with intercept a and slope b. With reference and reading in degrees Celsius, a has units °C and b is dimensionless. Error e is the part unexplained by the line. NIST includes this family among calibration models; we choose the affine case as a teaching assumption, not a universal sensor law.

y = a + b*x + e

Read it numerically: a=2 °C and b=1.1 turn 20 °C into 24 °C before small error e. At 40 °C the reading becomes 46 °C. Subtracting two degrees corrects the intercept but leaves scale error: at 40 we would still get 44. A comparison at one temperature cannot adequately separate slope and intercept. Different levels and checks of validity across the operating range are needed.

Build the data and estimate the correction

Use five synthetic references: 0, 10, 20, 30 and 40 °C. For each, generate two readings from 2+1.1x, adding −0.2 and +0.2 °C. These ten deterministic points have deliberately constructed symmetry; they are neither random samples nor repeatability tests. Code retains every point, removing no inconvenient observation. Symmetry makes parameter recovery transparent but much easier than real calibration.

To choose a line, define what fitting the points means. Minimizing squared vertical deviations penalizes larger deviations more strongly. Write J as the sum of [yᵢ−a−bxᵢ]². This criterion treats x as known; if reference uncertainty is substantial, that choice may be inadequate. A simple method is not permission to ignore experimental conditions.

J(a,b) = sum_i (y_i-a-b*x_i)^2 b_hat = sum_i((x_i-x_mean)*(y_i-y_mean)) / sum_i((x_i-x_mean)^2) a_hat = y_mean - b_hat*x_mean

The last expressions follow by setting derivatives of J with respect to a and b to zero: one forces zero mean residual, the other no residual correlation with centered x. The denominator measures reference spread; if all references coincide it is zero and slope is unidentified. Our means are 20 and 24 °C; numerator is 2,200 °C² and denominator 2,000 °C². We obtain b=1.1 and a=2 °C, checked by the program.

From reading to corrected value: reverse the question

So far we predicted the instrument reading from a reference. In operation we ask the reverse: what value corresponds to the received reading? Solve the line for x by subtracting the intercept and dividing by slope. Symbol x̂ denotes an estimate, not exact truth. Inversion requires nonzero b. With very small b, division amplifies even a small reading error; an elegant formula does not remove that problem.

x_hat = (y-a_hat)/b_hat y = 7.61 degC => x_hat = (7.61-2)/1.1 = 5.1 degC

Check the calculation with new references 5, 15, 25 and 35 °C, absent from fitting. Generate readings from the same relationship with alternating +0.11 and −0.11 °C deviations. The first reading is 7.61, corrected to 5.1, leaving +0.1 °C error. All four lie inside the reference range: this is not extrapolation testing. They are separate fitting-point checks, not validation on independent instruments.

Reference °CReading °CCorrected °CRaw error °CCorrected error °C
57.615.12.610.1
1518.3914.93.39-0.1
2529.6125.14.610.1
3540.3934.95.39-0.1

Every table column is in °C; error is estimate minus reference. We also report mean absolute error, MAE: sum absolute values and divide by four, retaining signed errors separately. Raw readings give 4 °C, corrected readings 0.1 °C. Code calculates both. Data construction favored improvement; it predicts neither improvement of a real sensor nor AI model accuracy.

MAE = (1/n)*sum_i abs(estimate_i-reference_i) raw_MAE = 4.00 degC ; corrected_MAE = 0.10 degC
Entirely synthetic data: left, deviations of ten fitting readings; right, errors on four separate checks before and after correction. Axes in °C, no hardware measurements.
Entirely synthetic data: left, deviations of ten fitting readings; right, errors on four separate checks before and after correction. Axes in °C, no hardware measurements.

The left panel plots reading minus reference: deviation increases with temperature, consistent with our constructed scale error. On the right, four check errors move from several positive degrees to ±0.1. Equal vertical scales make magnitude comparable; they do not turn four points into a statistical distribution. Plotting readings alone would look almost perfectly linear and hide how much deviation matters to a decision.

Correcting bias does not make a noisy instrument precise

Bias is systematic deviation; precision concerns repeated-measurement dispersion under defined conditions. They differ. NIST’s calibration failure discussion warns that correction does not solve poor precision or uncontrolled change over time. Our variability is chosen, small and symmetric; we estimated no daily drift, hysteresis or humidity dependence. A fixed correction can become wrong if the physical relationship changes after fitting.

We do not propose automatically deleting large deviations. An unusual reading may reveal an intermittent connection, real change or an unstabilized reference. Exclusion needs justification and traceability. Question the line too: curved residual patterns may indicate a non-affine relationship. More parameters can fit existing points better without making new measurements reliable. The decisive comparison uses conditions and points not used to choose the correction.

If tomorrow’s offset changes, the old correction can fail

Test stability directly. Add 0.55 °C to the four check readings without refitting coefficients. The previous correction divides that change by 1.1, shifting every estimate by +0.5 °C. Errors become +0.6, +0.4, +0.6 and +0.4 °C; MAE rises to 0.5 °C. These too are calculations on constructed data, not observed drift. Keeping a correction therefore does not remove the need for reference comparisons.

delta_x_hat = delta_y/b_hat = 0.55/1.1 = 0.5 degC MAE_after_assumed_offset_change = 0.5 degC

Inversion also shows local sensitivity: with fixed coefficients, a 0.2 °C reading deviation induces about 0.1818 °C estimate deviation, dividing by 1.1. This is not total measurement uncertainty. It excludes coefficient uncertainty, reference uncertainty, probe placement and model validity. Treating sensitivity as an accuracy interval would claim quality our example does not measure. Keep this distinction when comparing boards and algorithms.

An operational decision also needs a task-justified tolerance. A deviation acceptable for describing a room trend may not suit another process; we set no universal threshold. Near a decision boundary, ask how uncertain the value remains, not how many decimals software prints. Code produces many decimals through precise arithmetic; physical data do not become equally precise. Hence results retain units and assumptions without promising deployment-ready calibration.

Where the decision changes on an embedded device

Embedded means software runs in a dedicated device, often with limited memory, energy and time. Affine correction needs one subtraction and one division per sample, not network retraining. This counts operations, not measured latency: numerical representation, libraries and acquisition matter on hardware. Two coefficients are not the system’s whole RAM requirement. We report no milliseconds, watts or joules because we measured none.

Changing where correction is applied changes the meaning of model inputs. Correcting already corrected historical data adds error. If a model was trained on raw readings, rescaling inputs can alter decisions: reevaluate the whole chain against independent labels. Coefficient version, units, valid range and model version should accompany records. Replacing two numbers and seeing fewer alerts is insufficient.

Also compare a non-AI solution: a rule on a correctly measured physical quantity may suffice for a simple requirement. Conversely, calibration cannot repair a real change between temperature and process outcome. If the sensor agrees with independent references but prediction degrades on new labeled cases, retraining, new variables or process maintenance become reasonable hypotheses. There is no universal choice: evidence must separate measurement failure from task change.

What we established, and what remains

A counterexample established that one reading cannot identify the cause; we then numerically checked affine correction on separate synthetic values. We did not establish real sensor drift or a need to retrain a model. The practical decision is to obtain an independent comparison before intervening blindly. Improved measurement and improved final-task performance are separate checks; document both when changing an operational chain.

Real testing still needs the actual range, references with stated uncertainty, repetitions separated in time and relevant environmental conditions. Hardware also requires checking conversions, numerical precision, out-of-range handling and rollback of configurations. This case concerns neither clinical decisions nor a safety device. EL-AI is not presented as a sensor manufacturer or owner of these trials: editorial interest in embedded systems documents no available product or installation.

Attached code uses Decimal to preserve the chosen decimal inputs exactly. It creates ten pairs, calculates means and sums, estimates both parameters, then checks four points and the counterexample. Complexity is linear in pair count, as is the stored list. It is not a microcontroller library and measures no device memory. Assertions document execution of the expected arithmetic, not metrological, statistical or integration testing.

NIST/SEMATECH e-Handbook — Models for instrument calibration, section 2.3.6.1.

NIST/SEMATECH e-Handbook — Data collection, section 2.3.6.2.

NIST/SEMATECH e-Handbook — What can go wrong with calibration, section 2.3.6.4.

NIST/SEMATECH e-Handbook — Data analysis and model validation, section 2.3.6.5.

NIST/SEMATECH e-Handbook — Linear Least Squares Regression, section 4.1.4.1.

from decimal import Decimal as D
from pathlib import Path
import json,sys
# Entirely synthetic temperatures and reference values, not hardware measurements.
train=[(D(x),D('1.1')*D(x)+D(2)+e) for x in [0,10,20,30,40] for e in [D('-.2'),D('.2')]]
xbar=sum(x for x,y in train)/len(train);ybar=sum(y for x,y in train)/len(train)
b=sum((x-xbar)*(y-ybar) for x,y in train)/sum((x-xbar)**2 for x,y in train)
a=ybar-b*xbar
assert a==2 and b==D('1.1')
test=[]
for x,e in zip([5,15,25,35],[D('.11'),D('-.11'),D('.11'),D('-.11')]):
 x=D(x);y=D('1.1')*x+2+e;corrected=(y-a)/b
 test.append(dict(referenceC=str(x),readingC=str(y),correctedC=str(corrected),rawErrorC=str(y-x),correctedErrorC=str(corrected-x)))
raw=sum(abs(D(t['rawErrorC'])) for t in test)/len(test)
corrected=sum(abs(D(t['correctedErrorC'])) for t in test)/len(test)
assert raw==4 and corrected==D('.1')
# One reading admits distinct physical explanations without an independent reference.
assert D(20)+2==D(22)+0
shifted=[(D(t['readingC'])+D('.55')-a)/b-D(t['referenceC']) for t in test]
shiftedMAE=sum(abs(e) for e in shifted)/len(shifted)
assert shifted==[D('.6'),D('.4'),D('.6'),D('.4')] and shiftedMAE==D('.5')
assert sum((x-xbar)**2 for x,y in train)==2000
assert sum((x-xbar)*(y-ybar) for x,y in train)==2200
r=dict(shiftedErrorsC=[str(e) for e in shifted],shiftedMAEC=str(shiftedMAE),readingSensitivityForPointTwo=str(D('.2')/b),python=sys.version.split()[0],seed=None,scope='Synthetic affine calibration arithmetic, no hardware, no AI training, no certification or model accuracy benchmark',training=[dict(referenceC=str(x),readingC=str(y)) for x,y in train],interceptC=str(a),slope=str(b),test=test,rawMAEC=str(raw),correctedMAEC=str(corrected),identifiabilityCounterexample=dict(observedC='22',worldA=dict(trueC='20',offsetC='2'),worldB=dict(trueC='22',offsetC='0')))
Path(__file__).with_name('results.json').write_text(json.dumps(r,indent=2),encoding='utf8')
print(json.dumps(r))

Code, data, and instructions · JSON. Educational calculations executed with Python 3.14.0; figures with Matplotlib 3.11.2. AI-assisted analysis, without claiming peer review or human review. Original illustrative ImageGen cover: it does not document EL-AI people, premises, or installations. Sources accessed 30 October 2026.