you are here:   / News & Insights / Engineering Advantage Blog / Random Data Analysis Part 5: Accuracy of Your FFT - Parseval’s Theorem

Engineering Advantage

Random Data Analysis Part 5: Accuracy of Your FFT - Parseval’s Theorem

October 23, 2015 By: Jonathan Dudley

In my last blog I discussed the impact that selected inputs may have when performing a Fast Fourier Transform (FFT) analysis.  For this blog, I would like to discuss some key points when questioning the accuracy of your FFT.

Nyquist Criterion:

For a signal to be accurately reconstructed from discrete set of sampled points,  the sampling rate should be at minimum twice the maximum frequency of interest. Thus, the Nyquist frequency is defined as half of the sampling frequency of a discrete signal. The Nyquist rate is the minimum sampling rate that satisfies the Nyquist sampling criterion. If you wish to extract the frequency content from a 1 [kHz] signal then the Nyquist criterion tells us that our minimum required sample rate is 500 [Hz]. The most straightforward way to avoid aliasing is to ensure your sampling frequency is high enough to capture the spatial and or temporal variations in a given signal.

Parseval’s Theorem:

Parseval’s Theorem is a simple statement of the conservation of energy. The theorem states that the total energy computed in the time domain must equal the total energy computed in the frequency domain. In other words, no loss of energy (or power) should occur during the transformation from one space into another. For a continuous integrable function this is given by Equation 1.

For discretely sampled data series the relationship is simply the sums given by Equation 2.

The following section focuses on the built in function(s) in Python (Anaconda) and the implementation of Parseval’s Theorem. The snippet of code is well commented so adaption to another engine of choice should be somewhat seamless.

m=13

## Do FFT

# pfluc is the acquired signal from a uniformly sampled time-history

nfft = int(2**m) # size of each record to ensemble average

nlap = int(0) # No. of pts to overlap

fr = fs / float(nfft) # Calculate frequency resolution

k = int((N-nlap)/(nfft-nlap)) # No. of periodograms to average

# Get 2-sided FFT with appropiate scaling that yields [units^2/Hz]

Pxx,f = mpl.psd(pfluc,nfft,fs,window=mlab.window_hanning,scale_by_freq=True,noverlap=nlap)

parseval_side2 = (np.trapz(Pxx,f)/fs) # Num. int. PSD to get units [Pa^2]. Scale by fs for units matching

parseval_side1 = np.var(pfluc) # Get variance of time domain to get [Pa^2]

Error = (np.abs(parseval_side1-parseval_side2)/parseval_side1)*100 # Compute error

Please watch for Part 6 of this series where I will discuss some of the shortcomings of the FFT and discuss other potential data that can be extracted from your time series. If you have further experiences or questions please feel free to add a comment.