A Novel MFDFA Algorithm and Its Application to Analysis of Harmonic Multifractal Features

A power grid harmonic signal is characterized as having both nonlinear and nonstationary features. A novel multifractal detrended fluctuation analysis (MFDFA) algorithm combined with the empirical mode decomposition (EMD) theory and template movement is proposed to overcome some shortcomings in the traditional MFDFA algorithm. The novel algorithm is used to study the multifractal feature of harmonic signals at different frequencies. Firstly, the signal is decomposed and the characteristics of wavelet transform multiresolution analysis are employed to obtain the components at different frequency bands. After this, the local fractal characteristic of the components is studied by utilizing the novel MFDFA algorithm. The experimental results show that the harmonic signals exhibit obvious multifractal characteristics and that the multifractal intensity is related to the signal frequency. Compared with the traditional MFDFA algorithm, the proposed method is more stable in curve fitting and can extract the multifractal features more accurately.


Introduction
With a large number of nonlinear electrical equipment and electronic devices being applied in the power system, more and more harmonics are appearing in the power grid.Investigations show that the pollutions from harmonics have become increasingly severe in the power grid [1][2][3][4][5][6].Therefore, the study and analysis of harmonics has become an important research topic both at home and abroad.Traditional harmonic analysis methods mainly employ artificial neural network [7][8][9][10][11][12][13], Hilbert Huang Transform (HHT) [14,15], instantaneous reactive power [16], wavelet transform [17,18] and Fourier transform (FT) [19], etc.However, these methods ignore the self-similarity that exists in the time-domain waveform and the trend of harmonics, i.e., the so-called fractal characteristics [20].Therefore, bringing fractal characteristics into harmonic analysis is of great significance.
As one of the emerging theories for studying nonlinear systems, monofractal analysis has made great progress in the nonlinear signal analysis.However, monofractal is mainly a description of the overall average of the object of study, with the local characteristics of the signal being insufficiently characterized [21].Multifractal analysis [22,23] provides the ability to describe the local characteristics of the signal in detail.By combining multifractal and detrended fluctuation analysis, a multifractal detrended fluctuation analysis (MFDFA) algorithm [24] was proposed by Kantelhardt and Zschiegner et al.Since then, MFDFA has been quickly applied in a number of research areas, including market [25], temperature time series [26], seismic wave signal [27], vibration fault diagnosis [28], image processing [29], etc.For instance, in 2016, Zhao and He [30] analyzed the characteristics of speech signals based on MFDFA with moving, overlapping windows.To solve the shortcomings of the periodic trend affecting the Hurst index estimation in MFDFA, Fourier transform and MFDFA were combined to analyze the fluctuations in a high-frequency power load [31].Aiming to solve the subjectivity, lack of dynamics and theoretical basis for setting the risk threshold, the authors of Reference [32] proposed a method that combined surrogate data method and MFDFA to determine the prewarning threshold of electric load risk threshold based on historical load data.
The above-mentioned various methods can effectively describe the nonlinear system, especially the multifractal features of time series, but the analysis of time-series signals requires the process of detrending.New pseudofluctuation errors occur during the process.Such errors are mainly caused by two reasons.One is that the sequence is overfitting or underfitting due to the uncertainty of the order in the fitting polynomial function, while the other is that MFDFA uses a uniform sequence to segment data, resulting in discontinuity at sequence segmentation points.
To solve the above-mentioned problem, this paper proposes a new MFDFA algorithm based on empirical mode decomposition (EMD) and template movement.The multifractal characteristics of harmonic signals are analyzed by the new algorithm and a new method for determining the harmonic signals' characteristics is obtained.Since harmonic signals are susceptible to factors such as randomness, distribution factors and nonstationary factors [33], this paper first uses the wavelet multiresolution method to decompose the harmonic signals and the harmonic components, obtained at different frequencies.After this, the multifractal characteristics of the harmonic components are determined by the novel MFDFA algorithm.Finally, the proposed method and the traditional method are analyzed and compared.The analysis results verify the effectiveness of the proposed method.

Empirical Mode Decomposition Algorithm
The EMD algorithm is an adaptive signal time-frequency processing algorithm [34], which is mainly used for the processing of nonlinear and nonstationary signals [35,36].The procedure of EMD analysis is described as follows:

•
Find all local extreme points in signal x(t) and connect the extreme points smoothly through the cubic spline function to get the upper envelope e − (t), lower envelope e + (t)

Proposed Novel MFDFA Algorithm
The EMD algorithm successively decomposes n im f i (t) and one residual r n (t) from the signal and the residual part is used to replace the detrend fluctuation item in MFDFA.To be specific, the residual r n (t) replaces the detrend polynomial y v (t) and the result, after the least squares polynomial fitting, eliminates the residual sequences to obtain the fluctuations polynomial.After this, the fluctuation polynomial is divided into several segments.After calculating the fluctuation function F q (s) of the signal according to different q values, the generalized Hurst index of the signal can be obtained by finding the logarithmic least squares fitting slope of F q (s) and q.Finally, the multifractal spectrum of the signal can be obtained through the Legendre transform.The proposed algorithm is illustrated in the flowchart in Figure 1.Step-1: Set the time series as (),  = 1,2, … ,  and subsequently, construct a new sequence: where ̅ is the mean value of  , with ̅ = ∑ Step-2: The traditional MFDFA algorithm divides the new sequences  into  = (/) nonoverlapping intervals, each of which contains  data.Since  may not be divisible by , there will be a residual value.To fit all the data in the sequence in the calculation, another segmentation process is performed from the end of the sequence and thereafter, 2 equal length segments are obtained.
In this paper, the method of sequence segmenting MFDFA is improved by introducing the template movement and the number of sequences is increased from  or 2 to  −  + 1.
Step-3: For the  points in each  ( = 1,2, … ,2 ) interval, the least square method is used to fit the polynomial of the order k and the results are obtained: This paper introduces the EMD algorithm to replace the least squares fitting, to detrend sequence ().The remainder of the EMD decomposition is the trend polynomial that reflects the general trend of the signal, with  () =  ().
Step-4: Calculate the mean square error of  (, ) by the following: Step-5: For  −  + 1 segments, find the mean value of  (, ) and get the  −  fluctuation function  () by the following: (, ) ,  = 0 where ℎ() is the generalized Hurst index.ℎ() is related to the multifractal quality index () and their relation is described as follows: Step-1: Set the time series as x(k), k = 1, 2, . . ., N and subsequently, construct a new sequence: where x is the mean value of x k , with x = 1 N ∑ N k=1 x k .
Step-2: The traditional MFDFA algorithm divides the new sequences Y i into N s = int(N/s) nonoverlapping intervals, each of which contains s data.Since N may not be divisible by s, there will be a residual value.To fit all the data in the sequence in the calculation, another segmentation process is performed from the end of the sequence and thereafter, 2N s equal length segments are obtained.
In this paper, the method of sequence segmenting MFDFA is improved by introducing the template movement and the number of sequences is increased from N s or 2N s to N − s + 1.
Step-3: For the s points in each v (v = 1, 2, . . ., 2N s ) interval, the least square method is used to fit the polynomial of the order k and the results are obtained: This paper introduces the EMD algorithm to replace the least squares fitting, to detrend sequence Y(i).The remainder of the EMD decomposition is the trend polynomial that reflects the general trend of the signal, with Y v (i) = r v (i).
Step-4: Calculate the mean square error of F 2 (s, v) by the following: Step-5: For N − s + 1 segments, find the mean value of F 2 (s, v) and get the q − order fluctuation function F q (s) by the following: ) is a function of data length s and q − order.With an increase in s, F q (s) increases in the power-law relationship s h(q) ∝ F q (s) where h(q) is the generalized Hurst index.h(q) is related to the multifractal quality index τ(q) and their relation is described as follows: According to the Legendre transform, the relationship between the singular exponent α and the multifractal spectrum f (α) and h(q), is obtained in Reference [37]   α = h(q) + qh (q) = h(q) + q dh(q) dq ( 7) From the above equations, three characteristics in judging multifractal features based on the MFDFA method can be obtained [38]: Judging by q and h(q): If q is not related to h(q), the signal is monofractal.If q is related to h(q), the signal is multifractal.

2.
Judging by q and τ(q): If τ(q) is a straight line, the signal is monofractal.If q and τ(q) are nonlinear, the signal is multifractal.
If the curve of α and f (α) has a single-peak bell shape, the signal is multifractal.

MFDFA Feature Extraction Parameters
The singular exponent α reflects the degree of unevenness of the fractal sequence in the local probability measure distribution [39,40] while the multifractal spectrum width ∆α = α max − α min reflects the signal's intensity of the multifractal property.A larger ∆α highlights stronger multifractal characteristics in the signal and more severe fluctuations in the signal.The singular exponent α 0 , corresponding to the maximum value of multifractal spectrum f (α), reflects the randomness of the signal.α min is the smallest singular exponent, which reflects the intensity of local changes in the signal.A smaller α min indicates a stronger local singularity in the signal and a more intense local variation in the signal.
Therefore, based on the above analysis, ∆α, α 0 and α min can be used as the feature quantities after extracting the multifractal property of harmonic signals.

Signal Acquisition
In this paper, the electromagnetic flow meter contaminated by power harmonics was taken as the study object and the fractal characteristics of power system harmonics were analyzed.The advantages of the new MFDFA algorithm in the harmonic analysis of the power system were studied.
The electromagnetic flow meter adopted Faraday's law of electromagnetic induction and the conductor moving in the magnetic field generated an induced voltage.As shown in Figure 2, in the acquisition system, an alternating magnetic field was generated on the coil by controlling Switch 1, Switch 2, Switch 3 and Switch 4. Furthermore, the voltage induced by the flowing liquid was connected to the signal amplifying circuit through ELECTRODE+ and ELECTRODE-.Finally, the amplified signal was sent to the computer through the signal acquisition system after the analysis.The system adopted a low-frequency rectangular wave excitation mode, with the excitation frequency at 6.25 Hz and the excitation current at 25 mA.It is important to note that the induced voltage between ELECTRODE+ and ELECTRODE-is extremely susceptible to interference from power system harmonics as its amplitude is generally in the range of tens of uV and several mV. Figure 3 shows a waveform of the voltage after removing the DC offset signal between ELECTRODE+ and ELECTRODE-.The signal acquisition system adopted a sampling rate of 500 Hz, and the spectrum of the acquired signal was calculated and is presented in Figure 4.The spectrogram indicated that the signal contained obvious harmonic components.In addition to the fundamental component, the harmonic components were dominated by second-order (100 Hz) and fourth-order (200 Hz) harmonics.Figure 3 shows a waveform of the voltage after removing the DC offset signal between ELECTRODE+ and ELECTRODE-.The signal acquisition system adopted a sampling rate of 500 Hz, and the spectrum of the acquired signal was calculated and is presented in Figure 4.The spectrogram indicated that the signal contained obvious harmonic components.In addition to the fundamental component, the harmonic components were dominated by second-order (100 Hz) and fourth-order (200 Hz) harmonics.Figure 3 shows a waveform of the voltage after removing the DC offset signal between ELECTRODE+ and ELECTRODE-.The signal acquisition system adopted a sampling rate of 500 Hz, and the spectrum of the acquired signal was calculated and is presented in Figure 4.The spectrogram indicated that the signal contained obvious harmonic components.In addition to the fundamental component, the harmonic components were dominated by second-order (100 Hz) and fourth-order (200 Hz) harmonics.The original signal in Figure 3 was decomposed by the Mallat algorithm [41][42][43] and the actual frequency decomposition layer  was: was selected as 6.25 Hz and  was the sampling frequency of 500 Hz.The db24 wavelet was used to decompose the signal into 5 layers to obtain the high-frequency part of the original signal.The total bandwidth of the signal was 250 Hz and the frequency band range is shown in Table 1.The approximate signal (a5-a1) consisted of the low-frequency components of the signal and the detail signal (d5-d1) consisted of the high-frequency components of the signal.
The decomposition coefficient d3 contained the fundamental wave, as shown in Table 1, the decomposition coefficient d2 contained second-order harmonics, the decomposition coefficient d1 contained fourth-order harmonics and the waveform of d3-d1 is shown in Figure 5.

Layer
Frequency Band The original signal in Figure 3 was decomposed by the Mallat algorithm [41][42][43] and the actual frequency decomposition layer p was: f 0 was selected as 6.25 Hz and f s was the sampling frequency of 500 Hz.The db24 wavelet was used to decompose the signal into 5 layers to obtain the high-frequency part of the original signal.The total bandwidth of the signal was 250 Hz and the frequency band range is shown in Table 1.The approximate signal (a5-a1) consisted of the low-frequency components of the signal and the detail signal (d5-d1) consisted of the high-frequency components of the signal.
The decomposition coefficient d3 contained the fundamental wave, as shown in Table 1, the decomposition coefficient d2 contained second-order harmonics, the decomposition coefficient d1 contained fourth-order harmonics and the waveform of d3-d1 is shown in Figure 5.

Signal Analysis
Three components, d1, d2 and d3, were selected to calculate and analyze the local fractal characteristics by using the traditional MFDFA algorithm [44] and the proposed MFDFA algorithm.
Figure 6a,6b shows the multifractal spectrum of the three signal components after wavelet decomposition, using the traditional MFDFA algorithm and the new MFDFA algorithm. and () are single-peak bell-shaped graphs.The slope of the curve is obvious and the value of the singular index  is not unique.Therefore, all three signal components have typical multifractal characteristics.
Figure 7a,7b is the  − ℎ() curves of the three signal components, derived from the traditional MFDFA algorithm and new MFDFA algorithm, respectively.ℎ() of the three signal components gradually decreased with an increase in , as seen in in Figure 7, and the value of  varied with ℎ().In other words,  was related to ℎ().The local structure of the fundamental signal, both the second-order harmonic and fourth-order harmonic, were not uniform and therefore indicated the existence of obvious multifractal characteristics.From the comparison displayed in Figure 7a,7b, the curve of the traditional MFDFA algorithm had obvious bumps and inflection points, and the curve using the new algorithm was smoother and more stable than the traditional algorithm.Moreover, the density of the three curves of the new algorithm was also much lower than that of the traditional algorithm.This indicated that the proposed algorithm reduced the pseudofluctuation error, caused by the discontinuity of the data segmentation and obtained a more stable fluctuation function.
Figure 8a,8b exhibits the  − () curves of the three signal components, obtained using the conventional MFDFA algorithm and the new MFDFA algorithm, respectively.() is a curve where  and () have a nonlinear relationship.Furthermore, this was a convex-increasing function, which proved that the fundamental signal, the second-order harmonic and the fourth-order harmonic signals had multifractal characteristics.When  was greater than 0, the () values of the three components were more densely distributed.When  was less than 0, the () value distribution of the three signals was relatively sparse, and the () value of the high-frequency component d1 was lower than the () value of the high-frequency component d2.Furthermore, the () value of the low-frequency component d3 signal was the largest.From comparing Figure 8a,8b, we can see that the  − () curve of the new algorithm was smoother than the traditional algorithm, which verified the superiority of the new algorithm.
The fluctuation function was calculated according to the  values of different fluctuation orders, where  ranged from -5 to 5 and different  values were calculated to obtain different  () − () scatter plots.All  () − () calculated at all q values are plotted on Figures 9-11. Figure 9a with Figure 9b, Figure 10a with Figure 10b and Figure 11a

Signal Analysis
Three components, d1, d2 and d3, were selected to calculate and analyze the local fractal characteristics by using the traditional MFDFA algorithm [44] and the proposed MFDFA algorithm.
Figure 6a,b shows the multifractal spectrum of the three signal components after wavelet decomposition, using the traditional MFDFA algorithm and the new MFDFA algorithm.α and f (α) are single-peak bell-shaped graphs.The slope of the curve is obvious and the value of the singular index α is not unique.Therefore, all three signal components have typical multifractal characteristics.
Figure 7a,b is the q − h(q) curves of the three signal components, derived from the traditional MFDFA algorithm and new MFDFA algorithm, respectively.h(q) of the three signal components gradually decreased with an increase in q, as seen in in Figure 7, and the value of q varied with h(q).In other words, q was related to h(q).The local structure of the fundamental signal, both the second-order harmonic and fourth-order harmonic, were not uniform and therefore indicated the existence of obvious multifractal characteristics.From the comparison displayed in Figure 7a,b, the curve of the traditional MFDFA algorithm had obvious bumps and inflection points, and the curve using the new algorithm was smoother and more stable than the traditional algorithm.Moreover, the density of the three curves of the new algorithm was also much lower than that of the traditional algorithm.This indicated that the proposed algorithm reduced the pseudofluctuation error, caused by the discontinuity of the data segmentation and obtained a more stable fluctuation function.
Figure 8a,b exhibits the q − τ(q) curves of the three signal components, obtained using the conventional MFDFA algorithm and the new MFDFA algorithm, respectively.τ(q) is a curve where q and τ(q) have a nonlinear relationship.Furthermore, this was a convex-increasing function, which proved that the fundamental signal, the second-order harmonic and the fourth-order harmonic signals had multifractal characteristics.When q was greater than 0, the τ(q) values of the three components were more densely distributed.When q was less than 0, the τ(q) value distribution of the three signals was relatively sparse, and the τ(q) value of the high-frequency component d1 was lower than the τ(q) value of the high-frequency component d2.Furthermore, the τ(q) value of the low-frequency component d3 signal was the largest.From comparing Figure 8a,b, we can see that the q − τ(q) curve of the new algorithm was smoother than the traditional algorithm, which verified the superiority of the new algorithm.
The fluctuation function was calculated according to the q values of different fluctuation orders, where q ranged from −5 to 5 and different q values were calculated to obtain different logF q (s) − log(s) scatter plots.All logF q (s) − log(s) calculated at all q values are plotted on Figures 9-11. Figure 9a with Figure 9b, Figure 10a with Figures 10b and 11a with Figure 11b are logF q (s) − log(s), double logarithmic graphs corresponding to different q-valued harmonic signal components obtained by the traditional MFDFA algorithm and the novel MFDFA algorithm, respectively.h(q) MF-DFA result of d1 h(q) MF-DFA result of d2 h(q) MF-DFA result of d3 h(q) MF-DFA-EMD result of d1 h(q) MF-DFA-EMD result of d2 h(q) MF-DFA-EMD result of d3 h(q) MF-DFA result of d1 h(q) MF-DFA result of d2 h(q) MF-DFA result of d3 h(q) MF-DFA-EMD result of d1 h(q) MF-DFA-EMD result of d2 h(q) MF-DFA-EMD result of d3 τ(q) MF-DFA-EMD result of d1 τ(q) MF-DFA-EMD result of d2 τ(q) MF-DFA-EMD result of d3  -  -  In Figure 9, Figure 10 and Figure 11, the fluctuation function  () that was obtained by the two algorithms, changes with the scale  , which indicated that the signal had multifractal characteristics.Using the traditional MFDFA algorithm and the new MFDFA algorithm to analyze each harmonic component, the extracted multifractal characteristics parameters ∆,  and  are listed in Table 2.

Component
Traditional MFDFA New MFDFA In Figures 9-11, the fluctuation function F q (s) that was obtained by the two algorithms, changes with the scale s, which indicated that the signal had multifractal characteristics.Using the traditional MFDFA algorithm and the new MFDFA algorithm to analyze each harmonic component, the extracted multifractal characteristics parameters ∆α, α 0 and α min are listed in Table 2.In Table 2, the ∆α value of d2 is the smallest and the ∆α value of d3 is the largest.This represents that the singular exponential distribution range of the second-order harmonic component was the narrowest and the singular exponential distribution range of d1 was wider than that of d3.It shows that the fractal distribution of the second-order harmonic component signal was better than that of the fundamental signal and the fourth-order harmonic.The fourth-order harmonic showed better uniformity than the fundamental signal.Compared with the second-order harmonic, the fundamental wave of the fourth-order harmonic had more obvious multifractal features and the fluctuations were more obvious with scale changes.The α min of d1 is the smallest, indicating that the harmonic signal with the highest frequency had the strongest local fluctuation.It was known that the multifractal intensity of the fundamental signal was the largest and the signal distribution is relatively uniform.The multifractal intensity of the fourth-order harmonic signal was larger than that of the second-order harmonic and the signal distribution was the most uneven.These features can be well reflected in Figure 5.
Compared with the traditional MFDFA method, the characteristic extraction parameter values obtained by the new MFDFA method showed a significant decreasing trend.The multifractal spectrum curve distribution was narrowed in the new method, indicating that the new algorithm can reduce the error in the multifractal-characteristics analysis of harmonic signals and thus, make the curve fitting more stable.
The h(q) values obtained by analyzing the harmonic components using traditional MFDFA and the new MFDFA are presented in Table 3.The h(q) values corresponding to all q values in the Table 3 were less than 0.5 for the new MFDFA algorithm, which indicated that the low-frequency harmonic signal component and the high-frequency harmonic signal component were anticorrelated.The ∆h of d2 was the smallest and the ∆h value of d3 was the largest.Thus, if ∆h is larger, the multifractal is stronger, which resulted in the multifractal degree of the d2 component being the smallest and the multifractal degree of the fundamental signal being the strongest.Comparing the ∆h values obtained by the traditional MFDFA algorithm and the new algorithm, the results obtained by the new MFDFA algorithm were significantly smaller than the traditional algorithms, which indicated that the new algorithm could reduce the pseudofluctuation error and had higher precision than the traditional algorithm.The new MFDFA could more accurately characterize the multifractal features of the signal.
By using the characteristics of multifractal, the h(q) value distribution of different signals can be calculated under the condition of a fixed range of q values to measure the irregularity of multifractal in different frequency harmonic signals.

Conclusions
By using the new MFDFA algorithm proposed in this paper to analyze the multifractal characteristics of harmonic signals, the following conclusions are drawn:

•
The power grid harmonic signals in the flow meter signal exhibit multifractal characteristics.Furthermore, the multifractal intensity of the fundamental signal is the largest and the multifractal intensity of the higher-order harmonic is larger than that of the lower harmonic.

•
Compared with the traditional MFDFA algorithm, the new algorithm can effectively reduce the pseudofluctuation error caused by the discontinuity of the traditional algorithm, making the fitting curve more stable and more accurately revealing the multifractal characteristics of harmonic signals.

•
∆α, α 0 , α min and h(q) can provide theoretical and algorithmic support for grid harmonic management.

•
Although the algorithm shows good performance in the multifractal-characteristics analysis of harmonic signals, the new algorithm is mainly for integer subharmonics.Using the algorithm for analyzing noninteger harmonics still remains an interesting issue that needs to be studied.

( 4 )
() is a function of data length  and  − .With an increase in ,  () increases in the power-law relationship  ( ) ∝  ()

Figure 3 .
Figure 3.The original flow meter signal.

Figure 3 .
Figure 3.The original flow meter signal.

Figure 3 .
Figure 3.The original flow meter signal.

Figure 4 .
Figure 4.The spectrum of the original signal.

Figure 4 .
Figure 4.The spectrum of the original signal.

Table 1 .Figure 5 .
Figure 5.The high-frequency part of the wavelet decomposition.

Figure 5 .
Figure 5.The high-frequency part of the wavelet decomposition.

Figure 7 .Figure 8 .
Figure 7. q − h(q) curves of three signal components obtained using: (a) the traditional MFDFA algorithm; and (b) the new MFDFA algorithm.Electronics 2019, 8, x FOR PEER REVIEW 9 of 13

Figure 8 .
Figure 8. q − τ(q) curves of three signal components obtained using: (a) the traditional MFDFA algorithm; and (b) the new MFDFA algorithm.

Figure 10 .Figure 11 .
Figure 10.Double-log relation graph of low-frequency component d2 obtained using: (a) the traditional MFDFA algorithm; and (b) the new MFDFA algorithm.Electronics 2019, 8, x FOR PEER REVIEW 10 of 13

Figure 11 .
Figure 11.Double-log relation graph of low-frequency component d3 obtained using: (a) the traditional MFDFA algorithm; and (b) the new MFDFA algorithm.

Table 1 .
The frequency band of each layer by wavelet decomposition.

Table 2 .
∆ ,  and  values of the harmonic component computed analytically through traditional MFDFA and new MFDFA.

Table 2 .
∆α, α 0 and α min values of the harmonic component computed analytically through traditional MFDFA and new MFDFA.

Table 3 .
h(q) values of the harmonic signal computed analytically through MFDFA and the new MFDFA.