## 2 Materials and Methods
### Algorithm
#### 2.3.1 Wnnc-Fd mse_classification Algorithm
* An array x is created representing uniformly distributed values from 0 to 1, the size of the signal length y. This can serve as a normalized \"time\" axis for error generation. * The initial amplitude of ampl for generated errors is set to 1. * A set of size_values is defined. In pseudocode, these are sizes from length(y) in increments of 10 to \(2\times\text{length}(y)\). These dimensions will be used to resize the generated error signals. * A set of shifts from \(-\text{length}(y)\) to \(\text{length}(y)\) in increments of 1 is defined. These shifts will be used to offset the generated error signals relative to the beginning of the y signal. Cycle by error type (external FOR loop): The algorithm iterates over each error type err from the list errors. For each error type, the following process is performed:
* Initialization of minimum MSE for error type: The initial value of the minimum MSE mse_err for the current error type is set to a large number (e.g., \(10^{5}\)). This value will be updated if smaller MSE values are found. * Cycle by size (middle FOR loop): For each size \(s\) from the set size_values:
* Shift cycle (inner FOR loop): For each shift shift from the set of shifts: 1. Generating and resizing the error signal: A \"base\" error signal is generated using the Error_signal(err, x, ampl, 1) function for the current error type err, \"time axis\" x, amplitude ampl, and scale 1. Then, using the function resize_vector, the size of the generated error signal is resized to length \(s\). 2. Applying a shift to the error signal: Depending on the sign of the shift shift, the error signal Error is shifted either forward (if shift \(\geq\) 0) or backward (if shift \(<\) 0) relative to the signal y. The shift is realized by adding zeros to the beginning or end of the error signal and truncating the result to the length length(x). 3. Building a feature matrix: A feature matrix features_matrix of size \((\text{length}(x),2)\) is created. The first column of the matrix is filled with ones and the second column is filled with the shifted error signal arr_error. The first column with units allows us to account for the bias (constant) in the model. 4. Least Squares Method (LSM): A linear regression problem is solved using the least squares method to find the coefficients (\(\beta\)) minimizing the norm of the difference \(\|\text{features\_matrix}\cdot\beta-y\|^{2}\). This allows us to find the optimal linear combination (bias and scaling) of the error signal to approximate the \(y\) signal. 5. Calculating the approximated signal: The approximated signal approximated_signal is calculated as the product of the feature matrix features_matrix by the found coefficients coefficients. 6. Calculation of MSE: The mean square error (MSE) between the original signal \(y\) and the approximated signal approximated_signal is calculated. 7. Update Minimum MSE: If the calculated MSE value is less than the current minimum MSE mse_err for this error type, then mse_err is updated with this new, smaller MSE value. Saving the minimum MSE for the error type: After the size and shift cycles are completed, the minimum MSE value found mse_err for the current error type err is added to the array result. Determination of the best error type: After looping through all error types, the algorithm finds the index of the minimum value in the result array. This index corresponds to the error type that provided the lowest MSE when approximating the signal y. Output: The algorithm returns a list containing two elements: the name of the best error type (from the errors list) and the corresponding minimum MSE value. This indicates the error type that best \"explains\" the y signal structure in terms of MSE. Remarks  
The mse_classification algorithm is a classification method based on matching a signal to a set of reference \"error\" signals. Using MSE as an approximation quality metric, it quantifies how well each error type matches the input signal.