## 2 Materials and Methods
### Algorithm
#### 2.3.1 Wnnc-Fd mse_classification Algorithm  
The mse_classification algorithm is designed to classify the type of \"error\" or \"defect\" in a one-dimensional signal \(y\) by comparing it to a set of predefined \"error signals\" Error_signal of various types listed in the array errors. The classification is based on minimizing the mean square error (MSE) between the input signal and the approximation obtained using different error types, sizes, and shifts. The Main Steps of the Algorithm 8. Figure 1: Algorithm diagram. ```
1:Input:\(y\)--one-dimensional array of points,
2:errors--list of possible error types (e.g., [\"haar\", \"haar1\",...]),
3:leng--base length of the signal (e.g., 1000),
4:epsilon--a small threshold to check for proximity to 0,
5:\(n\)--fraction of zero (modulo) points for rejection. 6:Output: List: [name of the best error type, MSE]
7:if\((\text{length}(y)\leq leng\times 0.05)\) or (\(\sum_{i}(1\) if \(|y_{i}|<\epsilon\) else \(0)>\text{length}(y)\times n)\)then
8:return [\"Bad signal\", \"NaN\"]
9:endif
10:Initialize empty array \(result\)
11:\(x\leftarrow\) an array of uniform values from 0 to 1 of size \(\text{length}(y)\)
12:\(ampl\gets 1\)
13:size_values\(\leftarrow\{\text{length}(y),\text{length}(y)+10,\text{length}(y)+20, \ldots,2\times\text{length}(y)\}\)
14:\(shifts\leftarrow\{-\text{length}(y),-\text{length}(y)+1,\ldots,\text{length}(y)\}\)
15:for each err of errorsdo
16:\(mse\_err\leftarrow\) a large number (e.g., \(10^{5}\))
17:for each s of size_valuesdo
18:for each shift of \(shifts\)do
19: Calculate the vector of error values from the dictionary \(Error\leftarrow\text{resize\_vector}(\text{Error\_signal}(err,x,ampl,1),s)\)
20:if\(shift\geq 0\)then
21:\(arr\_error\leftarrow[0,\ldots,Error][:\text{length}(x)]\) forward-shifted
22:else
23:\(arr\_error\leftarrow[Error,0,\ldots,0][-\text{length}(x):]\) backward
24:endif
25: features_matrix \(\leftarrow\) a matrix of size \((\text{length}(x),2)\), where the first column is 1, the second column is \(arr\_error\)
26: Find the \(coefficients\) using the least squares method: \[\min_{\beta}\|\text{features\_matrix}\cdot\beta-y\|^{2}\]
27:\(approximated\_signal\leftarrow\text{features\_matrix}\cdot coefficients\)
28:\(mse\leftarrow\text{MSE}(y,approximated\_signal)\)
29:if\(mse<mse\_err\)then
30:\(mse\_err\leftarrow\)\(mse\)
31:endif
32:endfor
33:endfor
34: Add \(mse\_err\) to the \(result\) array
35:endfor
36: Find the index \(\arg\min_{i\in result}(result)\)
37:return\([errors[\arg\min_{i\in result}(result)],result[\arg\min_{i\in result}(result)]]\)
```  
**Algorithm 8** WoncFD_mse_classification  
Input data: The algorithm takes as input a one-dimensional array of points \(y\), a list of error type names errors, a base signal length leng, a small threshold \(\epsilon\) to check for proximity to zero, and a fraction of zero (modulo) points \(n\) to reject the signal. Preliminary Signal Checking: The algorithm performs an initial check on the input signal \(y\) to weed out \"bad\" signals that may lead to incorrect results. * Check signal length: The signal is checked for whether it is too short. If the length of \(y\) is less than or equal to 5% of the base length of leng (i.e., length(\(y\)) \(\leq 0.05\times leng\)), the signal is considered \"bad\". * Check for near-zero dots: The number of points in \(y\) whose absolute value is less than the specified small threshold \(\epsilon\) (\(|y_{i}|<\epsilon\)) is counted. If the number of such pointsexceeds a fraction \(n\) of the total signal length (i.e., the number of points \(|y_{i}|<\epsilon>n\times\text{length}(y)\)), the signal is also considered \"bad\". * Return for \"bad\" signals: If a signal is considered \"bad\" by one of the above criteria, the algorithm does not perform further classification and returns the list [\"Bad signal\", \"Nan\"] as the result, indicating that classification is impossible or unreliable. Initialization: For good signals, the algorithm continues the classification process:
* An empty result array is initialized to store MSE values for each error type.