# A Machine-Learning-Based Software for the Simulation of Regional Characteristic Ground Motion
## 2 Methods for Ground-Motion Simulation
### PCA for Extracting Ground Motions  
The sheer volume of data in the ground-motion database and the potential correlation between individual datum makes the data difficult to process. First, the characteristics of the ground-motion data in the database need to be extracted and processed (i.e., dimensionality reduction of the data). There are many methods of data dimensionality reduction in machine learning: PCA, linear discriminant analysis (LDA), locally linear embedding (LLE), and so on. However, LDA is a supervised dimensionality reduction algorithm; the stream shape learned by LLE can only be unclosed, and the sample set is dense and uniform. PCA, as an unsupervised dimensionality reduction algorithm, is easier to use and less demanding on data. We use PCA to obtain the reduced-dimensional characteristics from the ground-motion database, calling them characteristic ground motions. Specifically, we use PCA to reduce the dimensionality of the entire accelerated ground-motion record and to obtain a time series of data similar to the accelerated ground motion. It should be noted that PCA uses the ground shaking database of the target region to reflect the regional characteristics of the synthetic ground motion. For areas lacking ground-motion records, ground motion from areas with similar earthquake sources, propagation paths, and site conditions can be selected as ground-motion data. The application of the PCA algorithm for dimensionality reduction of the ground-motion dataset involves the following process:  
Dataset \(X\) needs to be reduced to \(k\) dimensions, where \(X\) is a matrix of \(n\) rows and \(m\) columns. The m represents the ground-motion durations, and 'n' stands for the number of ground motions. \(X\ =\ \begin{Bmatrix}x_{11},x_{12},x_{13},\ldots,x_{1m};\\ x_{21},x_{22},x_{23},\ldots,x_{2m}\\ \ldots\\ x_{n1},x_{n2},x_{n3},\ldots,x_{nm}\end{Bmatrix} \)  
1. Centralize all samples according to Equation (1); i.e., each bit of the feature minus its respective mean. \[x_{nm}\ =\ x_{nm}-\frac{1}{k}\sum_{i\ =\ 1}^{k}x_{nm},\] (1)
2. Calculate the covariance matrix of sample \(C\), \(C\ =\ \frac{1}{n}X^{T}X\)
3. Determine the eigenvalues and eigenvectors of the covariance matrix via the eigenvalue decomposition of the matrix covariance matrix. The eigenvalues are sorted from the largest to the smallest, and the largest \(k\) values are selected. The corresponding \(k\) eigenvectors are used as row vectors to form the eigenvector matrix P. \(P\ =\ \begin{Bmatrix}\lambda_{1}\\ \lambda_{2}\\ \ldots\\ \lambda_{k}\end{Bmatrix} \). The centralized data matrix is transformed into a new space constructed by \(k\) eigenvectors, i.e., \(Y=PX\), which in turn yields new orthogonal feature ground motion data. \[1-\frac{\sum_{i\ =\ 1}^{K}S_{ii}}{\sum_{i\ =\ 1}^{N}S_{ii}}\leq t, \tag{2}\]  
The selection of dimension K, representing the number of characteristic ground motions after dimensionality reduction, can be determined based on the scatter matrix S generated during singular value decomposition. Equation (2) can be used to calculate the minimum value of K that satisfies the error condition. If the value of t is 0.15, then it indicates that the PCA algorithm retains 85% of the main information from the original data. Consequently, the minimum number of characteristic ground-shaking that can be extractedunder this allowable error can be determined. The specific value of t can be determined according to the requirements for the error; therefore, different \(K\) values can be selected. Multiple characteristic ground motions that are independent of each other can be obtained by applying the abovementioned PCA method to the actual ground-motion records. The characteristic ground motions and actual ground-motion records in the database shared the same sampling rate. As a result, it is possible to synthesize the target ground motions by combining the characteristic ground motions in a linear manner and determining the combination coefficients that dictate their blending.