# A Method of Discriminating Between Power Swings and Faults Based on Principal Component Analysis
## 2 Principal Component Analysis  
PCA is designed to transform the data into a reduced form and to keep most of the original variance present in the initial data. In mathematical terms, PCA transforms the original data into a set of uncorrelated representations with fewer dimensions through a linear transformation, thereby extracting the main characteristic components of the data. From a geometric perspective, PCA projects the original data from the original coordinate system onto a new coordinate system with smaller dimensions by maximizing the divergence of the original data along the orthogonal directions in the new coordinate system. The main calculation steps of PCA are as follows [31].  
Define \(\mathbf{X}\) as an n \(\times\) m matrix which contains m number of n-dimensional vectors:  
\[\mathbf{X}=[\mathbf{x}_{1},\mathbf{x}_{2},\ldots,\mathbf{x}_{\text{m}}] \tag{1}\]  
where \(\mathbf{x}_{\text{k}}=[x_{1\text{k}},x_{2\text{k}},\ldots,x_{\text{n}\text{k}}]^{T}\), k = 1, 2, \(\ldots\), m.  
Define \(\mathbf{\overline{X}}\) as follows:  
\[\mathbf{\overline{X}}=\begin{bmatrix}x_{11}-\mu_{1}&x_{12}-\mu_{1}&\ldots&x_{1 \text{m}}-\mu_{1}\\ x_{21}-\mu_{2}&x_{22}-\mu_{2}&\ldots&x_{2\text{m}}-\mu_{2}\\ \vdots&\vdots&\vdots&\vdots\\ x_{n1}-\mu_{n}&x_{n2}-\mu_{n}&\ldots&x_{n\text{m}}-\mu_{n}\end{bmatrix} \tag{2}\]  
where \(\mu_{l}(\text{L}=1,2,\ldots,\text{n})\) is the average value of the data in the \(l\)th row of matrix \(\mathbf{X}\).  
Define matrix \(\mathbf{M}\) as follows:  
\[\mathbf{M}=\frac{1}{m}\mathbf{\overline{X}}\mathbf{\overline{X}}^{T} \tag{3}\]  
Calculate the eigenvalues of \(\mathbf{M}\) and arrange them in descending order. Take the first \(l\) eigenvalues for calculating the corresponding eigenvectors and orthogonalize them to obtain the orthogonal unit vectors \(\xi_{1},\xi_{2},\ldots,\xi_{l}\). These \(l\) unit vectors can be called the principal components (PCs), and \(\mathbf{x}_{\text{k}}\) can be expressed as follows:  
\[\mathbf{x}_{\text{k}}\approx q_{1\text{k}}\xi_{1}+q_{2\text{k}}\xi_{2}+\ldots+q_{ \text{lk}}\xi_{l} \tag{4}\]  
where \(q_{\text{ik}}(i=1,2,\ldots,l)\) is the coefficient.  
In addition, define matrix \(\mathbf{P}\) as follows:  
\[\mathbf{P}=[\xi_{1},\xi_{2},\ldots,\xi_{l}]^{T} \tag{5}\]  
The coordinates of the original data in the new coordinate system which applies these \(l\) PCs as the coordinate axes can be obtained by pre-multiplying matrix \(\mathbf{X}\) by matrix \(\mathbf{P}\).  
In order to display the relevant calculation steps and the effect of PCA on data more conveniently, consider an example of three points in the rectangular coordinate system shown in Figure 1.  
As Figure 1 shows, the coordinates of the three points are \(A(1,\,1)\), \(B(1,\,-1)\), and \(C(-1,\,-1)\). These three points cannot be discriminated by using the abscissa or ordinate alone. A matrix \(\mathbf{X}\) of size \(2\,\times\,3\) is formed by using the coordinates of these three points, and the eigenvalues (\(\lambda_{1}=4/3,\,\lambda_{2}=4/9\)) are calculated based on (2), (3), and (5). The eigenvector corresponding to \(\lambda_{1}\) is calculated as \(\xi_{1}=\left[\sqrt{2}/2,\sqrt{2}/2\right]^{T}\). In the one-dimensional coordinate system with \(\xi_{1}\) as the basis vector, the corresponding coordinates of the three points are obtained as \(\sqrt{2}\), \(0\), and \(-\sqrt{2}\), respectively. From the calculated results, PCA retains the characteristics of the original data when it reduces the dimensionality of the original data, and it makes the difference between the three points easier to distinguish.