Application of the method of ordinary least squares in the calibration of temperature, pressure and mass meters

The goal of this paper is applied the Ordinary Least Squares (OLS) method as a strategy in order to reduce the uncertainty measurement associated to the relevant physical quantities. Methodology: This work was motivated due to the efforts made in the measurement sciences to investigate alternative methods that allow obtaining greater metrological reliability of the results, that is, reducing the uncertainty associated with the measurement. Thus, the applied methodology consisted of the development of a computational code using the MatLab tool, in which an algorithm was programmed that supports the application of the OLS method. Results: The applied methodology allowed to: (i) obtain the matrix of the coefficients for polynomials of degrees 1, 2, 3 and 4 that adjust the experimental data; (ii) to draw the calibration curves for each of the obtained polynomials and (iii) to estimate the fit uncertainty (i.e.: the mean squared deviation) to specify the polynomial that best models the experimental data for a reliability level of 95.45 % (k = 2). The consolidated results confirmed a reduction in the uncertainty associated with the adjustment polynomial of 99.8% for the temperature measurement, 45.6% for the pressure measurement and 53.9% for the mass measurement. Conclusions: Finally, a discussion of the results is presented, confirming the effectiveness of the ordinary least squares method as a strategy to reduce the uncertainty associated with the calibration of measuring instruments.


Introduction
La The least method dates from the year 1801 when Italian astronomer Giuseppe Piazzi discovered the planet Ceres. Piazzi, was able to follow the planet's orbit continuously for 40 days. In that year, the scientific community developed several methods to estimate the planet's trajectory, from Piazzi's pioneering observation. The majority of observations were deficient. The only estimate, sufficiently precise -which allowed the German astronomer Franz Xaver Von Zach to determine the location of the planet Ceres at the end of the year 1801-was known as "the method of ordinary least squares" and proposed by a young man of 24 years, called Carl Friedrich Gauss [1]. Although Gauss had laid the foundations of his method in 1975, it was published in 1809 in his theory: Theoria Motus Corporum Coelestium in sectionibus conicis solem ambientium [2].
The fundamental theoretical of the ordinary least squares method proposed by Gauss consists of a technique of numerical analysis, where, given two variables -an independent and a dependent one-that come from a family of functions, it attempts to establish a continuous function that best [3].
From the statistical perspective, one of the conditions for applying the OLS method states that the errors of each measure must have a random distribution. The Gauss-Márkov theorem proves that the least squares estimators do not necessarily have to fit a normal probability distribution [4,5].

Fundamental theoretical
The main theoretical concepts are described in this section, as well as the mathematical foundation corresponding to the Ordinary Least Squares method (OLS) [6,7].

Polynomial interpolation
Considering fi, i = 1, 2, 3, ..., n, the value of fuction f calculated for n point of interpolation . The objective is to find the degree polynomial m wich interpolate f in those points. For this, it is necessary to solve the system of linear equations ≡ ( ) = ( ), thus, it is possible to solve the next equations system: The m+1 variables are the coefficients of the polynomial, a0, a1, ... , am and the system has n equations. Thus, the system: it is no possible to solution if m + 1 < n. Moreover, it has infinite solutions if m + 1 > n and will be determined only if m+1=n.

Mean squared deviation in the calibration of measuring instruments
Calibration is a process of comparing the values of a quantity by an instrument and by a standard, through which the first one can be traced in relation to the scale of the quantity in question [8]. However, since the values to be measured by the instrument are not the same as those verified during calibration, these results will only be useful if interpolation procedures were used, based on the overall performance of the instrument.
Thus, a statistical analysis based on the Ordinary Least Squares method is required. By this procedure a function (most often a polynomial) is adjusted to the calibration points identified by the standard values and the instrument values, so that for each value indicated by the instrument, the true value that would be obtained in a calibration (represented by the standard) within an uncertainty range estimated from the data of this experiment. Normally, the criterion for determining the coefficients of the fit function includes arguments such that the standard deviation of the measured magnitude is approximately the same for all points in the calibration range of the instrument, or at least an average value is estimated for it. This simplifying hypothesis allows the use of only one measurement at each point in the range, provided that a statistically sufficient number of points along the range is used. Thus, an average performance of the instrument along the range can be obtained. For a polynomial of degree m, the following expressions can be used to estimate the true value and mean squared deviation (often known as fit uncertainty) [9,10,11,12].
where, ci: polynomial coefficients of degree m; xi: value indicated by the instrument during calibration; m: degree of the polynomial; n: number of measured points; y (xi): dependent variable that represents the adjusted value; yi: true value measured by the standard during calibration; us: mean square deviation (uncertainty of fit).
The method of determining the coefficients is known as the Ordinary Least Squares method. Thus, the objective now is to determine values of the coefficients that minimize the mean squared deviation (us).
To achieve this goal, consider this result to fit any polynomial of the form for points ( , ), it is possible to do: Then, to find the points , 1 , ..., , we must solve the same system = . By performing the and calculations, you get: This procedure can be generalized to any shape fit curve: provided that the functions ( ) evaluated in the points result in linearly independent vectors, which is a necessary condition for the matrix to be invertible.
For a given degree of polynomial of degree m, we can define an adjustment uncertainty (us) as equal to the mean square deviation. It can be shown numerically that from a certain number of points used in the adjustment the value of the coefficients remains practically the same. Thus, depending on the repeatability of the instrument, it is possible to determine the minimum number of points to be used in the adjustment. This is normally in the range of 10-20. The literature presents various applications associated with multivariate regression methods [13,14,15,16,17], however, this work in particular focuses on the analysis of three of the magnitudes of greatest application at the industrial level: temperature, pressure and mass.

Computational algorithm developed for the application of the ols
This section presents in detail the MatLab code developed in the present work. In particular, the code applies the theoretical rationale related to the Ordinary Least Squares method, according to the following logic: (i) Enter the values of the independent variable (ii) Enter the values of the dependent variable (iii) Enter the total number of experimental points From this input data, the MatLab code determines: (i) Adjustment polynomials for grades 1, 2, 3 and 4 (ii) Coefficients for each of the polynomials obtained (iii) Mean squared deviation for each of the polynomials obtained (iv) Adjustment curves for each of the obtained polynomials Specification of the polynomial that best adjusts the experimental data from the lowest mean square deviation obtained. Three fundamental aspects stand out from the computational tool developed. They are described below: • Computer code development: In the first instance, the commands were developed so that the code is able to recognize the input data (i.e.: independent variable, dependent variable and number of experimental points). Once the code is executed, the input data will be requested first, and from this information the different results will be obtained for each adjustment polynomial.

• Adjustment polynomials for grades 1, 2, 3 and 4:
Once the input data are indicated, the code will calculate: (i) adjustment polynomials for degrees 1, 2, 3 and 4; (ii) coefficients for each adjustment polynomial; (iii) adjusted for the independent variable (y).
• Mean squared deviation for each of the polynomials obtained: The following are the commands developed for the estimation of the mean square deviation, also called, fit uncertainty. The smallest value for the uncertainty of fit determines the polynomial that best models the analyzed data.

Results and discussion
This section presents the application of MatLab code developed to specify the polynomial that best adjusts the experimental data in three different cases: (i) Thermistor, used for temperature control; (ii) manometer, used for pressure measurement; and (iii) Digital scale, used for mass control.

Application of the OLS method in temperature measurement
From the experimental data obtained in the experimental process, it was possible to use the MatLab code developed to obtain the polynomial that better adjusts the experimental data in order to obtain the uncertainty and the systematic errors associated to the temperature measurement for the full range of the thermometer.
Initially, calibration data were entered in the laboratory. The independent variable (x) corresponds to the resistance indicated by a multimeter and the dependent variable (y) denotes the temperature indicated by a digital thermometer of better metrological hierarchy (used as a calibration standard) with resolution of 0.01 o C.

Source: Own elaboration
Subsequently, the mean square deviation was estimated. In the following figure it can be observed that, for this particular instrument (calibration of a thermistor for temperature control), the polynomial that best adjusts the experimental data corresponds to a third degree equation.

Source: Own elaboration
Finally, the calibration curves were plotted for the four adjustment polynomials found, which confirm that the best fit corresponds to a degree 3 polynomial.

Source: Own elaboration
For the situation where the thermistor was calibrated there was a 99.72% reduction of the adjustment uncertainty due to the use of a second degree polynomial (us = 0.0033 o C) instead of a linear fit (us = 1.1994 o C). Thus, the calibration curves associated with each of the polynomials confirm that the best fit cannot be attributed to a linear equation. This frequently occurs at an industrial level during the calibration of this type of thermometer. This practice causes important errors in the measurement processes, decreases the metrological reliability of the results and, at the same time, has a strong impact on the quality of the final product. Thus, the OLS method allows us to verify that the best fit corresponds to a 3rd degree polynomial, which is much more in line with the physical nature of a thermistor.

Application of the OLS method in pressure measurement
Following a methodology similar to th2at explained for the calibration of the thermistor, from the experimental data obtained in the experimental process, it was possible to use the MatLab code developed to obtain the polynomial that best adjusts the experimental data in order to obtain the uncertainty and systematic errors associated with pressure measurement for the full range of the inclined well manometer. The independent variable (x) corresponds to the manometer pressure indication and the dependent variable (y) denotes the pressure indicated by a standard manometer with a resolution of 0.01 PSI.

Source: Own elaboration
Subsequently, the mean square deviation was estimated. In the following figure it can be observed that, for this particular magnitude and instrument (manometer of pressure), the polynomial that best adjusts the experimental data corresponds to a fourth degree equation. Finally, the calibration curves were plotted for the four adjustment polynomials found, which confirm that the best fit corresponds to a degree 4 polynomial.

Source: Own elaboration
In relation to the calibration of the manometer, a 45.59% reduction was obtained due to the application of a grade 4 polynomial (us = 0.0821 PSI) in detriment of the use of a grade 1 polynomial (us = 0.1509 PSI), which is often used industrially. So, in the case of a pressure gauge, it is common to associate its operation with a first degree polynomial. This practice, in principle, can result in a very good approximation because the elastic deformation of the instrument's bourdon is proportional to the increase in pressure. However, during the operation of the gauge, the bourdon begins to show mechanical wear and there is a possibility that the elastic limit is overcome by the applied stress, thus passing to a plastic deformation that leads to an irreparable hysteresis error. In this case, the only solution is not to operate the pressure gauge and replace it, since the hysteresis error cannot be corrected. Thus, once the manometer is in operation, a first degree polynomial does not adequately model the physical nature of the problem. In this work, this theory is verified experimentally, giving as a result that a fourth degree polynomial offers a lower adjustment uncertainty when compared to the uncertainty of a linear polynomial.

Application of the OLS method in mass measurement
OIML R-76-1 (2006) defines scales as non-automatic weighing instruments which require the intervention of an operator during the weighing process, for example to place or withdraw the mass of the the result of the measurement. The calibration of these instruments makes use of standard masses, which are classified by OIML R-111-1 (2004) according to their accuracy class, taking into account the maximum mass error as a function of their nominal value, i.e.: E1 accuracy, E2, F1, F2, M1, M2 and M3 (less accuracy).
Following with the examples where the least squares method is used for the calibration of measuring instruments used in industry, this section is intended for the situation where a digital scale is calibrated. In the experimental process was used a digital scale (300 kg capacity and 0.2 kg resolution). This instrument was calibrated with the aid of a Hewlett Packard digital multimeter model 34401A (resolution: 0.001 mV) and standard masses with accuracy class M1 and E1. Initially, calibration data were entered in the laboratory. The independent variable (x) corresponds to the voltage indication in mV of the digital multimeter and the dependent variable (y) is the mass indicated by the digital scale in kilograms.

Source: Own elaboration
Subsequently, the mean square deviation was estimated. In the following figure it can be observed that, for the case of the digital scale calibration, the polynomial that best adjusts the experimental data corresponds to a second degree equation. Finally, the calibration curves were plotted for the four adjustment polynomials found, which confirm that the best fit corresponds to a polynomial of degree 2. Although the electronic manufacture of the digital scale is programmed to perform a linear adjustment between two points (the manufacturer calls: "auto-calibration process"), in terms of the uncertainty associated with the measurement, a more robust analysis must be carried out in order to increase the metrological reliability of industrial processes resulting from mass measurement. The OLS method applied in this work, for mass measurement, confirmed that it was possible to reduce the uncertainty of the adjustment by 53.91% by the use of a second degree polynomial (us = 0.0059 kg) when compared to the application of a linear polynomial (us = 0.0128 kg). Thus, the use of a higher degree polynomial effectively models the physical nature of the problem, offering greater metrological reliability, that is, less uncertainty associated with the measurement.