## 3 Methodology of Complementary Filter Calibration
### Performance Evaluation of the Optimized Signal  
First, we compare how the algorithm reduced the mean absolute error (MAE) for individual angle values. This evaluation highlights the effectiveness of the algorithm in minimizing systematic errors across the tested pitch and roll angles. The summarized results are visualized in the Figure 9, illustrating the reduction in MAE achieved for each angle. A detailed analysis follows to interpret these findings. A significant reduction in the mean absolute error (MAE) is evident, with decreases ranging from at least 15% to nearly 25%. The maximum permissible absolute error was set at 0.5% of the roll and pitch angle range. In this study, we adopted a range of \(\pm\)30\({}^{\circ}\), which translates to a maximum permissible error of \(\pm\)0.30\({}^{\circ}\). Analyzing the signal, we observe that the maximum positive error for the pitch angle is 0.2035\({}^{\circ}\), while for the roll angle, it is 0.2898\({}^{\circ}\). These values remain well within the defined error tolerance. Similarly, the maximum absolute negative errors for pitch and roll angles are 0.2142 and 0.2759, respectively. This indicates that both the maximum and minimum error values comply with the permissible error criterion, providing an additional safety margin. Thus, the established goal was achieved successfully. The graphical representation below (Figure 10) provides a clear visualization of these maximum and minimum error values, highlighting their compliance with the permissible error tolerance. In addition to these observations, the mean squared error (MSE) values, which range from 0.002 to 0.005 across the angles analyzed, offer further insight into the filter's performance. Given that the permissible absolute error is 0.3, these small MSE values indicate that the errors are tightly clustered around zero. This demonstrates the high precision achieved through the optimization of the complementary filter parameters. Figure 9: Reduction in mean absolute error (MAE) for observed angles. The detailed MSE values for the observed pitch and roll angles are presented in Table 3, further supporting the robustness of the applied methodology. We further propose a set of metrics to evaluate signal behavior in scenarios where either it exceeds the maximum permissible error threshold or, due to specific requirements, this threshold is deliberately narrowed to assess the extent of its reduction. The principal metric quantifies the occurrences of signal excursions beyond the specified limits, comprising the number of crossings above the upper limit, below the lower limit, and the total number of excursions outside the permissible range, calculated as the sum of the preceding two quantities. These metrics enable the estimation of the probability that the signal exceeds the prescribed boundary conditions. We conducted observations with the boundary set at four times the mean absolute error, i.e., \(\pm\)0.168 for the pitch angle and \(\pm\)0.232 for the roll angle. This boundary is significantly tighter than the standard permissible limits defined earlier. Below, we present a table summarizing the predicted probabilities (Table 4). The up-crossing and down-crossing probabilities, representing the likelihood of exceeding the upper and lower boundaries, are both approximately \(10^{-4}\). The overall probability of exceeding the boundary, combining both up-crossing and down-crossing events, is in the order of \(10^{-3}\), indicating that such occurrences are extremely rare. This metric provides information about individual excursions, which theoretically last for a duration of 0.02 s.  
Figure 10: Maximal and minimal errors for pitch and roll angles.