Skip to main content
Modules / Tools / Sensor calibration fit tool

Sensor calibration fit tool

Fit calibration data with a straight line or a polynomial, with optional temperature terms, and see the residuals, non-linearity, hysteresis and maximum error.

Quality statisticsFree to useHow it worksSourcesWhere it helps

Fills the inputs below with typical figures. Replace any of them with your own.

Calibration data

One row per reading: the reference input, the measured output, then optionally the temperature. Add up or down at the end of a row for a sweep direction. A header line is skipped.

11 rows read, 11 different input values.

For example kPa, g, C.

For example V, mV, counts.

The output span over the rated range. Empty or 0 uses the span of the measured outputs.

Fit
Use the calibration

Enter a reading to find the input it corresponds to, inside the calibrated range.

Fitted curve
output = 0.50048 + 0.040009 x input
Output in V, input in kPa
Maximum error
0.001773 V
0.0443% of full scale. Referred to the input: 0.04431 kPa
Non-linearity
0.0443% of full scale
0.001773 V from the least squares straight line
Hysteresis
no result
Needs up and down readings at the same input
Repeatability
no result
Needs repeated readings at the same input
R squared
0.9999994
RMS error 0.001019 V, standard error of the fit 0.001127 V
Input for the reading
49.9768 kPa
Reading 2.5 V

Sign in to save your inputs and come back to them later.

Residuals against input
Line chart of Residual (V) against Input (kPa), one line. The same numbers are in the table under the chart.-0.00100.001020406080100Input (kPa)Residual (V)
Show the data as a table
Residuals against input
Input (kPa)Residual (V)
0-0.00108
10-0.000871
20-0.00046
300.00165
40-0.0000382
500.00177
600.00138
70-0.000505
80-0.000495
90-0.000884
100-0.000473
Fitted coefficients
TermValueStandard errorUnit
a0: a0 (offset)0.50048180.000636V
a1: a1 x0.040008910.0000107V per kPa
Points and residuals
RowInput (kPa)Output (V)Temperature (C)DirectionFitted (V)Residual (V)Residual (% FS)
100.4994nonenone0.500482-0.001082-0.027
2100.8997nonenone0.900571-0.0008709-0.0218
3201.3002nonenone1.30066-0.00046-0.0115
4301.7024nonenone1.700750.0016510.0413
5402.1008nonenone2.10084-0.00003818-0.000955
6502.5027nonenone2.500930.0017730.0443
7602.9024nonenone2.901020.0013840.0346
8703.3006nonenone3.30111-0.0005055-0.0126
9803.7007nonenone3.70119-0.0004945-0.0124
10904.1004nonenone4.10128-0.0008836-0.0221
111004.5009nonenone4.50137-0.0004727-0.0118

How it works

A sensor is calibrated by measuring its output at known inputs and fitting a curve that turns later readings back into an input. This tool fits an end-point line, a least squares line, a polynomial or a two variable curve with temperature terms to pasted calibration data, and reports the coefficients, the residuals, the maximum error, the non-linearity, the hysteresis and the repeatability.

  1. Choose the model. The end-point line joins the mean outputs at the lowest and highest inputs. The best-fit line and the polynomials minimise the sum of squared residuals. The two variable fit adds terms in the temperature difference from a reference temperature, so the offset and the sensitivity can drift with temperature.line: output = a0 + a1 x; polynomial: output = a0 + a1 x + a2 x^2 + a3 x^3; two variables: output = a0 + a1 x + a2 x^2 + b1 (T − Tref) + c1 x (T − Tref)
  2. Solve by least squares. Each term is a column of a design matrix A and the outputs form a vector y. The coefficients minimise the squared residual. The tool solves it by Householder QR factorisation after scaling every column to unit length, which stays accurate for the small orders used and avoids the loss of precision that the normal equations suffer when the columns are nearly dependent.minimise | A c − y |^2; A = Q R; R c = Q^T y; standard error of a coefficient = s x sqrt( [ (A^T A)^−1 ]jj ), s^2 = SSres / (n − p)
  3. Residuals and error. The residual of each point is the measured output minus the fitted output. The maximum error is the largest residual size, given in output units, as a percentage of the full scale output and referred to the input by dividing by the local slope. R squared compares the residual with the spread of the outputs about their mean.residual = y − fit(x, T); error % FS = 100 x max |residual| / FS; R^2 = 1 − SSres / SStot
  4. Non-linearity, hysteresis and repeatability. Non-linearity is the largest distance of the mean output at each input from the least squares straight line through those means, using readings corrected to the reference temperature where temperature terms are fitted. Hysteresis is the largest difference between the mean up sweep and the mean down sweep at the same input. Repeatability is the spread of repeated readings at the same input, direction and temperature, given as a range and as a pooled standard deviation.non-linearity % FS = 100 x max |mean(y) − line(x)| / FS; hysteresis % FS = 100 x max |mean(up) − mean(down)| / FS
  5. Use the calibration in reverse. In service the sensor gives a reading and the input is wanted. The tool finds the input within the calibrated range at which the fitted curve equals the reading, at the temperature you give for the two variable fit. A reading outside the range returns no input rather than an extrapolation.find x with fit(x, T) = reading

Assumptions

  • The reference inputs are far more accurate than the sensor, so all the scatter is taken as error in the output.
  • The scatter in the output is similar at every input (equal weights). A sensor whose noise grows with the signal may need a weighted fit.
  • Full scale is the output span of the sensor over its rated range. If you leave it empty the span of the measured outputs is used.
  • Definitions of non-linearity differ between data sheets: best-fit line, end-point line and others. This tool uses the least squares line through the mean outputs, and gives the end-point fit as a separate model. State which one your data sheet uses.
  • A temperature column is in the same unit throughout, and the reference temperature is where the offset and sensitivity coefficients apply.

Limits and warnings

  • A polynomial that is too flexible follows noise and extrapolates badly. Keep the order low and use more points than coefficients.
  • The standard errors assume independent errors of equal size. They are guides, not a full uncertainty budget.
  • Hysteresis and repeatability need an up and down sweep, and repeated points, in the data. Without them the tool says so.
  • Self heating, time drift and humidity are not modelled. Treat the fit as valid only for the conditions of the calibration.
  • The inverse is found inside the calibrated range only, and assumes the fitted curve is monotonic there.

Sources

The methods and default figures rest on these public sources. The wording here is our own; read the source for its full text.

Where it helps

The lifecycle stages this tool serves: 1 stage in 1 lifecycle.

Method notev1Formula, ranges, sources and limits

Fits calibration data with a straight line, a polynomial or a two variable curve with temperature terms, and reports the coefficients, the maximum error, the non-linearity, the hysteresis and R squared.

Formula

line: output = a0 + a1 x; polynomial: output = a0 + a1 x + a2 x^2 + a3 x^3; two variables: output = a0 + a1 x + a2 x^2 + b1 (T − Tref) + c1 x (T − Tref); minimise | A c − y |^2; A = Q R; R c = Q^T y; standard error of a coefficient = s x sqrt( [ (A^T A)^−1 ]jj ), s^2 = SSres / (n − p); residual = y − fit(x, T); error % FS = 100 x max |residual| / FS; R^2 = 1 − SSres / SStot; non-linearity % FS = 100 x max |mean(y) − line(x)| / FS; hysteresis % FS = 100 x max |mean(up) − mean(down)| / FS; find x with fit(x, T) = reading

Inputs
InputUnitRange it holds forComes from
Fitchoiceendpoint, linear, poly2, poly3, tempYour figure
Reference temperaturetemperature unit of the dataanyYour figure
Include x^2 (two variable fit)choiceyes, noYour figure
Include x^3 (two variable fit)choiceyes, noYour figure
Include temperature (two variable fit)choiceyes, noYour figure
Include temperature squared (two variable fit)choiceyes, noYour figure
Include input times temperature (two variable fit)choiceyes, noYour figure
Full scale output, 0 for the measured spanoutput unitsfrom 0Your figure

Outputs: Offset coefficient a0 (output units); First order coefficient a1 (output units per input unit); Maximum error (% of full scale); Non-linearity (% of full scale); Hysteresis (% of full scale); R squared (fraction); RMS error (output units).

Assumptions

  • The reference inputs are far more accurate than the sensor, so all the scatter is taken as error in the output.
  • The scatter in the output is similar at every input (equal weights). A sensor whose noise grows with the signal may need a weighted fit.
  • Full scale is the output span of the sensor over its rated range. If you leave it empty the span of the measured outputs is used.
  • Definitions of non-linearity differ between data sheets: best-fit line, end-point line and others. This tool uses the least squares line through the mean outputs, and gives the end-point fit as a separate model. State which one your data sheet uses.
  • A temperature column is in the same unit throughout, and the reference temperature is where the offset and sensitivity coefficients apply.

Uncertainty: The coefficients are exact least squares solutions for the data entered. Their standard errors assume independent errors of equal size; the real calibration uncertainty also holds the reference uncertainty and drift.

Known limits

  • A polynomial that is too flexible follows noise and extrapolates badly. Keep the order low and use more points than coefficients.
  • The standard errors assume independent errors of equal size. They are guides, not a full uncertainty budget.
  • Hysteresis and repeatability need an up and down sweep, and repeated points, in the data. Without them the tool says so.
  • Self heating, time drift and humidity are not modelled. Treat the fit as valid only for the conditions of the calibration.
  • The inverse is found inside the calibrated range only, and assumes the fitted curve is monotonic there.

Where the method comes from

Follows NIST/SEMATECH e-Handbook of Statistical Methods, section 4.1.4.1, Linear Least Squares Regression (opens in a new tab). The arithmetic here is the same; the platform claims no improvement on it.

Reference example, checked by test: Worked example in this method note: five points at inputs 0 to 4 with outputs 1.0, 3.1, 4.9, 7.1, 8.9 and a full scale of 8. The least squares line is 1.04 + 1.98 x; the residuals are −0.04, 0.08, −0.10, 0.12, −0.06, so the largest error is 0.12 (1.5% of full scale) and R squared is 1 − 0.036 / 39.24 = 0.99908. Offset coefficient a0 1.04; First order coefficient a1 1.98; Maximum error 1.5; Non-linearity 1.5; R squared 0.999083; RMS error 0.084853.

Versions

  • v1 (2026-10-25): First version, built from the tool idea.

All models in the register

Terms on this page

Full scale
The maximum input or output value a converter or measurement channel can represent, used as the reference for expressing errors and noise.
Datasheet
The authoritative customer-facing document giving a part's electrical characteristics, absolute maximum ratings, timing, pinout, package drawing and ordering information.

The full glossary

Need help acting on this?

Tell us what you're after and leave your email: we'll connect you with the right person on the Hub.