# Research on CNN-BiLSTM Fall Detection Algorithm Based on Improved Attention Mechanism
## 3 Materials and Methods
### Data Preprocessing  
#### 3.2.1 Kalman Filtering  
In 1960, [PERSON] published a paper on linear filtering of discrete data using recursive methods and proposed Kalman filtering [32]. Kalman filtering, an algorithm based on the linear system state equation, is the most widely used filtering method at present and can make the optimal estimation of the system state through inputting and outputting of the observation data of the system. Since the measured data include the influence of noise and interference from the system, the optimal estimation can also be regarded as a filtering process [33]. [PERSON] et al. [34] show a smoother waveform after Kalman filter processing of the experimental data.  
In view of the sensors being easily influenced by various factors, such as vibration, temperature and electromagnetic interference, which affects the final classification accuracy of human activities [35], Kalman filtering is introduced to process the data and eliminate noise before extracting the features of the collected acceleration and angular velocity data.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Activity** & **Samples** \\ \hline Fall & 560 \\ Walk & 500 \\ Jog & 500 \\ Jump & 500 \\ Up stairs & 500 \\ Down stairs & 500 \\ Sit down & 500 \\ \hline Total & 3560 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Number of data collection samples.  
Figure 4: (**a**) Walking, jogging, jumping, going up stairs, going down stairs, sitting down acceleration graphs; (**b**) Walking, jogging, jumping, going up stairs, going down stairs, sitting down angular velocity graphs.  
Figure 3: (**a**) Slipping when walking, falling in a faint, falling when sitting down and falling when getting up acceleration graphs; (**b**) slipping when walking, falling in a faint, falling when sitting down and falling when getting up angular velocity graphs.  
The data before and after processing are shown in Figure 5. The main formulas of the Kalman filter are as follows:  
\[X(k|k-1)=AX(k-1|k-1)+BU(k) \tag{1}\]  
\[P(k|k-1)=AP(k-1|k-1)A^{T}+Q \tag{2}\]  
\[K(k)=\frac{P(k|k-1)H^{T}}{HP(k|k-1)H^{T}+R} \tag{3}\]  
\[X(k|k)=X(k|k-1)+K(k)[Z(k)-HX(k|k-1)] \tag{4}\]  
\[P(k|k)=(1-K(k)H)P(k|k-1) \tag{5}\]  
wherein \(X(k|k-1)\) is the priori state estimation value at time \(k\), which is the result of the prediction at time \(k\) based on the best estimation at the last time point (time \(k\)-1); \(X(k|k)\) and \(X(k-1|k-1)\) represent the state estimation values at time \(k\) and time \(k-1\), respectively; \(P(k|k-1)\) is the priori covariance of estimation at time k; \(P(k|k)\) and \(P(k-1|k-1)\) represent the posteriori covariance of the estimation at time \(k\) and time \(k-1\), respectively; \(Z(k)\) is the measured value; \(U(k)\) is the observed noise; \(K(k)\) is the Kalman gain; \(A\) is the state transition matrix; \(Q\) is the process excitation noise covariance; \(H\) is the transformation matrix from state variables to measurements; and \([Z(k)-HX(k|k-1)]\) is the residual of the actual observation and predicted observation, which are used together with the Kalman gain to correct the priori. Kalman filtering has two major calculation steps: In the first step, Formulas (1) and (2) are used to obtain the estimated value. In the second step, Formulas (3)-(5) are the state-updated equations of the Kalman filter, which are used to correct the previously estimated value to obtain the optimal estimated value at the current moment and to update the minimum mean square error matrix to prepare for the use of the Kalman algorithm at the next moment. Repeated updating of the equations can reduce the influence of noise on the sensor data, thus improving the accuracy of fall detection.