# Study on Denoising Method of Weld Defect Signal Based on SSA-VMD-WPD
## 3 Results and Discussion
### Denoising Characterization
#### 3.2.1 SSA Analysis  
The specific implementation steps of the SSA algorithm were as follows [36; 37]:  
Step 1: Determine the number of individuals n in the population, the ratio of different roles, the maximum number of iterations \(t_{max}\), the dimension m of the parameters to be optimized, and the safety threshold \(ST\). Then, initialize the positions of n sparrows according to Equation (1).  
\[X=\begin{bmatrix}x_{1,1}&x_{1,2}&\cdots&x_{1,m}\\ x_{2,1}&x_{2,1}&\cdots&x_{2,m}\\ \vdots&\vdots&\vdots&\vdots\\ x_{n,1}&x_{n,2}&\cdots&x_{n,m}\\ \end{bmatrix} \tag{1}\]  
Since the energy level depends on the individual's fitness value, generally, discoverers had higher energy. Therefore, calculate the fitness value _fi_ for all individuals. The fitness value for all individuals can be calculated using Equation (2). Individuals with higher fitness values act as discoverers within the population, guiding the search for food direction and area.  
\[F_{X}=\begin{bmatrix}f([x_{1,1}&x_{1,2}&\cdots&x_{1,m}])\\ f([x_{2,1}&x_{2,1}&\cdots&x_{2,m}])\\ \vdots&\vdots&\vdots&\vdots\\ f([x_{n,1}&x_{n,2}&\cdots&x_{n,m}])\\ \end{bmatrix} \tag{2}\]  
Step 2: Perform position updates while calculating the fitness value for each individual. The positions of the discoverers are updated according to Equation (3):  
\[X^{t+1}_{i,j}=\left\{\begin{array}{ll}X^{t}_{i,j}\cdot\exp\Bigl{(}\frac{-i} {\alpha\cdot t_{\max}}\Bigr{)}&R_{2}<ST\\ X^{t}_{i,j}+Q\cdot L&R_{2}\geq ST\\ \end{array}\right. \tag{3}\]  
Figure 10: Slagging Defects. (The red boxes showed the slagging defects at the corresponding signals).  
where \(t\) is the current iteration number, \(j=1\), \(2\), \(\ldots\), \(m\), \(m\) is the dimension of the parameters to be optimized, \(t_{max}\) is the maximum number of iterations, \(\alpha\in(0,1]\), alert value \(R_{2}\in(0,1]\), safety threshold \(ST\in[0.5,1]\), \(Q\) is a random number following a normal distribution, and \(L\) is a matrix \(1\times d\) with all elements equal to \(1\). When the alert value was lower than the safety threshold, indicating no predators, the discoverers engaged in extensive exploration. When the alert value exceeds the safety threshold, indicating the presence of predators, all sparrow individuals must move quickly to safe areas.  
The position update formula for followers is  
\[X_{j,j}^{t+1}=\left\{\begin{array}{ll}Q\cdot\exp\left(\frac{X_{\text{worst}} ^{t}-X_{i,j}^{t}}{\varepsilon^{2}}\right)&i<n/2\\ X_{p}^{t+1}+\left|X_{i,j}^{t}-X_{p}^{t+1}\right|\cdot A^{+}\cdot L&\text{ otherwise}\end{array}\right. \tag{4}\]  
Equation (4): \(X_{p}\) represents the best position occupied by the discoverers, \(X_{\text{worst}}\) represents the worst position, and \(A^{+}=A^{T}(AA^{T})^{-1}\), where \(A\) is a randomly assigned matrix \(1\times d\) with elements \(-1\) or \(1\).  
The position update formula for warners is as follows:  
\[X_{i,j}^{t+1}=\left\{\begin{array}{ll}X_{\text{best}}^{t}+\beta\cdot\left|X_ {i,j}^{t}-X_{\text{best}}^{t}\right|&f_{i}<f_{g}\\ X_{i,j}^{t}+K\cdot\left(\frac{\left|X_{i,j}^{t}-X_{\text{worst}}^{t}\right|}{ \left(f_{i}-f_{m}\right)+A}\right)&f_{i}=f_{g}\end{array}\right. \tag{5}\]  
In this equation, \(X_{\text{best}}\) represents the globally optimal position; \(f_{i}\) is the current fitness, \(f_{w}\) is the worst fitness, \(f_{g}\) represents the best fitness; \(\beta\) is a random number following a normal distribution with mean \(0\) and variance \(1\), used to control step size; \(K\) is a random number, and \(K\in[-1,1]\), \(\lambda\) is a constant used to ensure the denominator is not zero.  
Step 3: Stop iteration when the maximum number of iterations is reached and obtain the optimized parameter results under the condition of the best fitness value.