# PEMFC RUL Prediction for Non-Stationary Time Series Based on Crossformer Model
## 3 Methods
### Dain  
DAIN serves as a deep learning layer aimed at learning how to normalize based on the distribution of the data rather than relying on fixed normalization formulas. As depicted in Figure 4, this layer consists of three sub-layers. Its ultimate goal is to obtain the transformation factors \(\alpha^{i}\) and \(\beta^{i}\) as described in Equation (3).  
\[\widetilde{x}_{1:T}=\left(x_{1:T}-\alpha^{i}\right)\div\beta^{i} \tag{3}\]  
Figure 3: De-stationary-Crossformer model.  
The first layer is primarily responsible for mapping the data to an appropriate region in the feature space. Through this step, it ensures that the input time series data have a suitable distribution in the feature space, aiding the model in better capturing the non-stationary characteristics of the data. For the input time series \(x_{1:T}\in\mathbb{R}^{T\times D}\), the mean \(a^{i}\) within the T time range is initially calculated using Equation (4) to provide an initial estimate for the current time series, which is used to estimate the distribution of the sequence generated at the current time.  
\[a^{i}=\frac{1}{T}{\sum_{j=1}^{T}x_{j}} \tag{4}\]  
Then, the scaling factor \(\alpha^{i}\) is calculated using Equation (5) and serves as the output of the first layer:  
\[\alpha^{i}=W_{a}a^{i} \tag{5}\]  
In this equation, \(W_{a}\) is a learnable parameter matrix. Subsequently, the output of the first layer is obtained through a linear transformation as given in Equation (6). This output is responsible for the moving measurements of the input time series in each dimension and is therefore also referred to as the output of the adaptive movement layer.  
\[\hat{x}_{1:T}=x_{1:T}-W_{a}a^{i} \tag{6}\]  
The task of the second layer is to linearly scale the data to increase or decrease their variance. This adjustment of the data's scale makes them more suitable for the learning process of the model. The process of linear scaling is dynamically adjusted based on the actual input time series, making it adaptive. Similarly, the standard deviation within the T time range is first calculated using Equation (7) as an initial estimate of the data offset.  
\[b^{i}=\sqrt{\frac{1}{T}{\sum_{j=1}^{T}\left(x-a^{i}\right)^{2}}} \tag{7}\]  
Then, the scaling factor \(\beta^{i}\) is calculated using Equation (8) to scale the moving measurements from the previous layer.  
\[\beta^{i}=W_{b}b^{i} \tag{8}\]  
In this equation, \(W_{b}\) is a learnable parameter matrix. The output of this layer can be calculated using Equation (9). This output is responsible for appropriately scaling the data based on the variance in the moving measurements.  
\[\widetilde{x}=\left(x_{1:T}-W_{a}a^{i}\right)\div W_{b}b^{i} \tag{9}\]  
Figure 4: Structure of DAIN.  
Finally, the third layer performs gating operations, which nonlinearly suppress features unrelated to the target task. This helps the model focus more on task-relevant information, enhancing the model's ability to represent the input data. This layer uses the mean \(c^{i}\) of the output from the previous layer as an initial estimate, according to Equation (10):  
\[c^{i}=\frac{1}{T}\sum_{j=1}^{T}\widetilde{x}_{j} \tag{10}\]  
Then, the sigmoid nonlinearity activation function is utilized to suppress features unrelated to the prediction. The specific calculation is performed using Equation (11) as follows:  
\[\widetilde{\widetilde{x}}=\widetilde{x}\odot\mathit{sigmod}\left(W_{c}c^{i}+ d\right) \tag{11}\]  
where \(W_{c}\) and \(d\) are learnable gating parameters. The entire process of deep adaptive instance normalization is adaptive, meaning that the normalization scheme depends on the actual time series input to the network, and this process is trainable. In this way, the model can dynamically adapt to the characteristics of different data distributions, enhancing its ability to model non-stationary data.