# Absolute Capacitance Measurement by Direct Digital Fitting of Proportional Coefficient
## 3 Measurement Program Design
### Gross Error Handling  
In the process of k-value fitting, due to the influence of random noise, the data sampled by the ADC may have data points with large deviations, which affect the accuracy of \(k\) calculation during the fitting process and further affect the accuracy of capacitance tolerance calculation. Therefore, excluding gross errors can effectively improve the accuracy of this measurement method.  
The threefold standard deviation criterion (3\(\sigma\) principle) is a commonly used outlier detection method in statistics for determining whether a data point significantly deviates from the main part of the data set. According to the 3\(\sigma\) principle, points where the original data points exceed three times the standard deviation of the fitted curve are considered gross errors. In order to eliminate the coarse error, when choosing to replace the coarse error points in the original data with the points on the fitted k-value curve, and then re-fit the original data, this can effectively weaken the influence of noise points on the measurement accuracy.  
\begin{table}
\begin{tabular}{c c c} \hline
**State of Affairs** & **k-Value Confidence Interval** & **Width of k-Value Confidence Interval** \\ \hline Before data smoothing & (0.005181, 0.005405) & 0.000224 \\ After data smoothing & (0.005299, 0.005303) & 0.000004 \\ \hline \end{tabular}
\end{table}
Table 1: Comparison of confidence intervals for the scale factor k before and after data smoothing.  
Figure 7: Comparison of k-value fitting plots before and after smooth. (**a**) Before smoothing. (**b**) After smoothing.  
The specific treatment is shown in Equation (23), the fitted curve is F(n), and the standard deviation of its fitted curve is \(\sigma\). \(y_{2}\)(n), z1(n) are the same as in Section 2.3 denote the input signal and output signal difference and output signal difference, respectively. When the coarse value is replaced by the fitted value, the re-fitting calculation can be performed.  
\[\left\{\begin{aligned} & F(n)=k*y_{2}(n)\\ &|F(n)-z_{1}(n)|>3\sigma\\ & z_{1}(n)=F(n)\end{aligned}\right. \tag{23}\]  
As shown in Figure 8, a fitting plot of the k-value under the influence of gross error during charging of a single cycle at a nominal capacitance of 3000 pF and a re-fitting plot of the k-value after substituting the fitted value for the gross error are shown. The * sign indicates discrete raw data and the red curve indicates the fitted k-value curve. Where the horizontal coordinate represents the input signal and output signal difference y2(n), and the vertical coordinate represents the output signal difference z1(n).  
It can be clearly seen in the image that before removing the gross errors, there exist several raw data points with large errors, which have a more serious effect on the least squares fitting. For the fitted curves obtained before and after removing the gross errors, we calculated the confidence intervals for them, and the specific results are shown in Table 2:  
According to the information presented in Figure 8 and Table 2, after fitting the data instead of gross error, the data involved in fitting are more dense, the fitting of k-value is significantly weakened by the influence of noise points, the width of k-value confidence interval decreases significantly after removing the gross error, the accuracy of slope estimation improves, the correlation between the data enhances, and it is an effective way of improving the accuracy of measurement.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**State of Affairs** & **k-Value Confidence Interval** & **Width of k-Value Confidence Interval** \\ \hline Gross errors exist & (0.005246, 0.005332) & 0.000129 \\ Gross error removal & (0.005246, 0.005332) & 0.000086 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison of confidence intervals of scale factor k before and after gross error removal.  
Figure 8: Image of k-value fitting before and after gross error processing. (**a**) Before eliminating gross errors. (**b**) After eliminating gross errors.