## 5 Simultaneous Calibration of Offsets and Gains  
### Consensus Algorithm  
The previous sections have been devoted to offset and gain calibration taken separately, in order to gradually introduce the basic lines of reasoning. Following further the main ideas from the literature [34; 35; 36; 44; 45; 46], it is possible to develop algorithms for the _simultaneous correction_ of both offsets and gains in the presence of nonlinear sensor characteristics.  
The calibration algorithms can be constructed in a straightforward way starting from Sections 3 and 4. Namely, we define in the general case  
\[\hat{z}^{i}_{t}=\hat{a}^{i}_{t}y^{i}_{t}+\hat{b}^{i}_{t}=\hat{a}^{i}_{t}\hat{ a}^{i}x_{t}+v^{i}_{t}+\hat{a}^{i}_{t}\beta^{i}+\hat{b}^{i}_{t} \tag{22}\]  
and \(\hat{e}^{ij}_{t}=\hat{z}^{i}_{t}-\hat{z}^{i}_{t}\), so that we have  
\[\hat{e}^{ij}_{t}=x_{t}(\hat{g}^{j}_{t}-\hat{g}^{i}_{t})+\hat{f}^{j}_{t}-\hat{f }^{i}_{t}+\hat{g}^{j}_{t}v^{j}_{t}-\hat{g}^{i}_{t}v^{i}_{t}, \tag{23}\]  
where \(\hat{g}^{i}_{t}=\alpha^{i}\hat{a}^{i}_{t}\) and \(\hat{f}^{i}_{t}=\hat{a}^{i}_{t}\beta^{i}+\hat{b}^{i}_{t}\). It follows that, if the gain correction is performed by using the full-consensus algorithm from Section 4, we can aim to asymptotically attain \(\hat{g}^{j}=\hat{g}^{i}\) at consensus. This implies that \(\hat{f}^{j}_{t}=\hat{f}^{i}_{t}\), leading to the conclusion that the algorithm for simultaneous offset and gain correction is obtained by using both (4) and (16), modified in such a way that (4) includes an expression resulting from the gain-correction algorithm [44; 45]. In other words, we now have the same calibration recursion as that shown in Section 4, in which we introduce \(\hat{z}^{i}_{t}\), defined by (22), instead of \(\hat{z}^{i}_{t}=y^{i}_{t}+\hat{b}\), adopted in Section 3. In terms of the corrected parameters, we have (17) for the gain parameters defined in Section 4 and the following complete recursion for \(\hat{f}^{i}_{t}=\hat{a}^{i}_{t}\beta^{i}+\hat{b}^{i}_{t}\), i.e.,  
\[\hat{f}^{i}_{t+1}= \hat{f}^{i}_{t}+\delta\sum_{j}\gamma_{ij}(\hat{f}^{j}_{t}-\hat{f }^{i}_{t})+\delta x_{t}\sum_{j}\gamma_{ij}[\hat{g}^{j}_{t}(1+\frac{v^{j}_{t}} {x_{t}})-\hat{g}^{i}_{t}(1+\frac{v^{i}_{t}}{x_{t}})]\] \[+\delta\Delta x_{t}^{2}\alpha^{i}\beta^{i}\sum_{j}\gamma_{ij}[ \hat{g}^{j}_{t}(1+w^{j}_{t})-\hat{g}^{i}_{t}(1+w^{i}_{t})](1+w^{i}_{t}). \tag{24}\]  
At the sensor network level, we have the following vector-matrix model:  
\[\hat{f}_{t+1}=\hat{f}_{t}+(I+\delta\Gamma)\hat{f}_{t}+\delta x_{t}\Gamma(I+V^ {\prime}_{t})\hat{g}_{t}+\delta x_{t}^{2}\alpha\delta\Gamma^{\
u}_{t}\delta_{t} \tag{25}\]where \(V^{\prime}_{t}=\text{diag}\{\frac{v_{t}^{1}}{x_{t}},\ldots,\frac{v_{t}^{n}}{x_{t}}\}\) and \(\beta=\text{diag}\{\beta^{1},\ldots,\beta^{n}\}\).  
The convergence properties of the recursions (17) and (25), based on full consensus, can be analyzed, directly extending the above-given results. The convergence of the first recursion has already been clarified. The dynamics of the second recursion follows from Theorem 1 after introducing a necessary modification, resulting from the fact that the offset estimate now contains an additional input term generated by (17). One easily concludes, therefore--on the basis of the results concerning the gain correction taken alone--that the composition of (17) and (25) is practically inapplicable.