## 3 Calibration  
The analytical characterization of a foodstuff, especially with the aim of its authentication, may imply the quantitative determination of one or more constituents of the samples at hand or of one or more of their global properties, such as the sensory scores for some specific attributes, the iodine value or the dry matter content. Moreover, one would ideally want such a determination to be rapid (in some cases, almost instantaneous, to allow controls to be conducted on- or in-line), non-invasive or at least non-destructive, not needing the specimens to be subjected to clean-ups or pre-treatments, and, possibly, not encompassing the use of auxiliary reagents or organic solvents. All these requirements point in the direction of spectroscopic techniques, which, depending on the applications concerned, possess most or all of the aforementioned characteristics. However, the possibility of using spectroscopy to quantify the properties of a food product is conditional, on the one hand, to the existence of a relation between the measured signal and the response to be estimated and, on the other hand, to the postulation of a reasonable mathematical formulation to express (or at least approximate) this relation. In other words, quantifying the value of a property, \(y\), based on the measurement of a spectroscopic signal, \(\mathbf{x}\), rests on inferring a functional relation, \(f\), that connects them so that:  
\[y=f(\mathbf{x}) \tag{5}\]  
Unfortunately, the exact form of the function \(f(\mathbf{x})\) linking a measured spectrum to the property to be determined is unknown and cannot be retrieved from first principles. A reasonable guess of \(f(\mathbf{x})\) should be therefore empirically drawn, through a procedure which is called calibration [43; 44; 45]. Calibration makes use of known data to approximate the functional relation in Equation (5). In particular, it requires that, for a sufficient number of samples (which are usually gathered in a so-called _training set_), both the recorded spectra and the values of the property(-ies) of interest are available. For example, if NIR spectroscopy is used for the quantification of the protein content in wheat, in order to proceed with the calibration phase, one should not only collect the NIR spectra of the training samples, but also determine their protein content by, e.g., reference methods such as Kjeldahl [46] or Dumas [47]. Afterwards, a mathematical expression of the function \(f(\mathbf{x})\) is explicitly assumed: this function will depend not only on \(\mathbf{x}\), but also on the values of some adjustable parameters (_coefficients_), whose estimation is the core issue in calibration. In many cases, \(f(\mathbf{x})\) can be assumed to be linear; this means that, if \(f\) spectral variables are recorded (i.e., if \(\mathbf{x}\) is a \(J\)-dimensional vector of light intensity/absorption measurements, with elements \(\left[ \begin{array}{cccc}x_{1}&x_{2}&,&x_{3}&\cdots&x_{J}\end{array} \right]\)), Equation (5) can be written as:  
\[y=\hat{y}+e=b_{1}x_{1}+b_{2}x_{2}+b_{3}x_{3}+\cdots+b_{J}x_{J}+e \tag{6}\]  
where \(\hat{y}\) is the approximation of \(y\) provided by the linear function defined by the coefficients \(b_{1},b_{2},b_{3},\cdots,b_{J}\), and \(e\) is the _residual_, i.e., the difference between the true value of \(y\) and \(\hat{y}\). In calibration, the available \((\mathbf{x},y)\) pairs constituting the training set of data are used to calculate the coefficients in Equation (6) through regression, according to some user-defined criterion of optimality. Since the aim of calibration is to use the measured signal \(\mathbf{x}\) as the basis to obtain the best _prediction_ of \(y\), in the majority of cases such a criterion involves the minimization of the residuals (_least squares_).