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.
- 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.
Show the data as a table
| Input (kPa) | Residual (V) |
|---|---|
| 0 | -0.00108 |
| 10 | -0.000871 |
| 20 | -0.00046 |
| 30 | 0.00165 |
| 40 | -0.0000382 |
| 50 | 0.00177 |
| 60 | 0.00138 |
| 70 | -0.000505 |
| 80 | -0.000495 |
| 90 | -0.000884 |
| 100 | -0.000473 |
| Term | Value | Standard error | Unit |
|---|---|---|---|
| a0: a0 (offset) | 0.5004818 | 0.000636 | V |
| a1: a1 x | 0.04000891 | 0.0000107 | V per kPa |
| Row | Input (kPa) | Output (V) | Temperature (C) | Direction | Fitted (V) | Residual (V) | Residual (% FS) |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 0.4994 | none | none | 0.500482 | -0.001082 | -0.027 |
| 2 | 10 | 0.8997 | none | none | 0.900571 | -0.0008709 | -0.0218 |
| 3 | 20 | 1.3002 | none | none | 1.30066 | -0.00046 | -0.0115 |
| 4 | 30 | 1.7024 | none | none | 1.70075 | 0.001651 | 0.0413 |
| 5 | 40 | 2.1008 | none | none | 2.10084 | -0.00003818 | -0.000955 |
| 6 | 50 | 2.5027 | none | none | 2.50093 | 0.001773 | 0.0443 |
| 7 | 60 | 2.9024 | none | none | 2.90102 | 0.001384 | 0.0346 |
| 8 | 70 | 3.3006 | none | none | 3.30111 | -0.0005055 | -0.0126 |
| 9 | 80 | 3.7007 | none | none | 3.70119 | -0.0004945 | -0.0124 |
| 10 | 90 | 4.1004 | none | none | 4.10128 | -0.0008836 | -0.0221 |
| 11 | 100 | 4.5009 | none | none | 4.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.
- 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) - 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) - 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 - 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 - 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.
- NIST/SEMATECH e-Handbook of Statistical Methods, section 4.1.4.1, Linear Least Squares Regression (opens in a new tab), National Institute of Standards and Technology, Online edition, accessed 25 October 2026. Least squares fitting of models that are linear in the parameters, including polynomials.
- NIST/SEMATECH e-Handbook of Statistical Methods, section 2.3.6, Instrument calibration over a regime (opens in a new tab), National Institute of Standards and Technology, Online edition, accessed 25 October 2026. Calibration curves fitted by least squares over a range, and their use in reverse to calibrate later readings.
Where it helps
The lifecycle stages this tool serves: 1 stage in 1 lifecycle.
More quality statistics tools
- Process capability (Cpk) calculator
- Gauge repeatability and reproducibility calculator
- Statistical process control chart
- Test limit and guard band calculator
- Outlier screening (PAT) limit calculator
- Yield learning curve projector
- Bin and grade mix planner
- Sensor error budget builder
- Process assessment rating calculator
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
| Input | Unit | Range it holds for | Comes from |
|---|---|---|---|
| Fit | choice | endpoint, linear, poly2, poly3, temp | Your figure |
| Reference temperature | temperature unit of the data | any | Your figure |
| Include x^2 (two variable fit) | choice | yes, no | Your figure |
| Include x^3 (two variable fit) | choice | yes, no | Your figure |
| Include temperature (two variable fit) | choice | yes, no | Your figure |
| Include temperature squared (two variable fit) | choice | yes, no | Your figure |
| Include input times temperature (two variable fit) | choice | yes, no | Your figure |
| Full scale output, 0 for the measured span | output units | from 0 | Your 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.
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.
Tell us what you're after and leave your email: we'll connect you with the right person on the Hub.