## 3 PAI-Rife Algorithm
### Designed Phase Angle Interpolation and Criterion  
The variation interval of the phase angle is limited to \(0\sim\pi\), which is more stable than the amplitude [24]. Therefore, the algorithm proposed in this paper used phase angle interpolation to estimate the frequency. Since the window function only reduced the spectrum leakage, it will not affect the amplitude and phase angle changes. For the convenience of understanding, the spectrum of the raw sinusoidal signal is used for analysis in the following. The spectrum of a general sinusoidal signal can be expressed as  
\[X(k)\approx\frac{A\sin[\pi(k-k_{0})]}{2\sin[\pi(k-k_{0})/N]}e^{j[\theta_{0}-(k- k_{0})\pi]}=A(k)\cos[\varphi(k)]+jA(k)\sin[\varphi(k)]. \tag{6}\]  
The magnitude of the phase angle corresponding to the spectrum is determined by \(A(k)\) and \(\varphi(k)\). When \(k_{1}\) is the quantization frequency point index corresponding to the maximum spectrum, \(A(k_{1})\) and \(A(k_{1}+1)\) are positive values, and \(A(k_{1}-1)\) is a negative value. Assuming \(0<\theta_{0}-(k_{1}-k_{0})\pi<\pi/2\), we can conclude that \(\varphi(k_{1})\) is in the first quadrant, and both \(\varphi(k_{1}-1)\) and \(\varphi(k_{1}+1)\) are in the third quadrant. Based on formula (6), we generated the following results:  
\[ \begin{cases}X(k_{1})>0\\ X(k_{1}+1)<0\\ X(k_{1}-1)>0\end{cases} . \tag{7}\]  
The above analysis shows that the phase angles corresponding to \(k_{1}\) and \(k_{1}-1\) are in the first quadrant, and the phase angle corresponding to \(k_{1}+1\) is in the third quadrant. Since the phase angle at \(k_{1}+1\) varies considerably, the interpolation correction will be performed between \(k_{1}\) and \(k_{1}+1\). The direction of frequency deviation correction is likewise judged according to the degree of phase angle change. Similarly, the above analysis can be obtained by the same conclusion when \(\varphi(k_{1})\) is in other quadrants. Combining Formulas (2) and (5), we obtained the frequency deviation factor based on the phase angle:  
\[\delta_{1}=r_{1}\frac{|angle[F(k_{1})]|}{|angle[F(k_{1})]|+|angle[F(k_{1}+r_{ 1})]|}, \tag{8}\]  
where, \(angle(\cdot)\) is the phase angle function, \(r_{1}\) is the correction direction. The judgment conditions for the correction direction are as follows:  
\[r_{1}= \begin{cases}1,&|angle[F(k_{1}+1)]|\geq|angle[F(k_{1}-1)]|\\ -1,&|angle[F(k_{1}+1)]|\leq|angle[F(k_{1}-1)]|\end{cases} . \tag{9}\]  
If \(r_{1}=1\), the actual frequency point is located to the right of the position \(k_{1}\) corresponding to the maximum spectrum; if \(r_{1}=-1\), the actual frequency point is located to the left of the position \(k_{1}\). In order to analyze the correction ability of the phase angle interpolation method proposed in this paper to the frequency estimation value, we calculated the corrected frequency using the formula (10). Then, the estimated standard deviation of the phase angle interpolation method is compared with the spectral interpolation method of the Rife algorithm  
\[\hat{f}_{0}=\frac{(k_{1}+r_{1}\delta_{1})f_{s}}{N}, \tag{10}\]  
where, \(f_{s}\) is the sampling frequency. The comparison results of two different interpolation methods are shown in Figure 1. Compared with the spectral interpolation method, the phase angle interpolation has better anti-interference performance, which reduces the estimation error of the Rife algorithm when the estimated frequency point is close to the quantized frequency. However, since the phase angles at \(k_{1}\pm 1\) are approximately equal, when the estimated frequency point is located in the center area of the two quantized frequency points, the correction direction in this area is easily misjudged, and the frequency estimation error is increased. We analyzed that there is an optimal correction interval for the frequency deviation factor in the phase angle interpolation mode, which is expressed as \(0.1\leq\delta_{1}\leq 0.4\). When \(0\leq\delta_{1}<0.1\), due to the influence of noise, the optimal estimation performance is not achieved.