Tools › Electrical and Controls › Signal Processing › Signal Analysis (FFT and PSD)


Signal Analysis (FFT and PSD)

Paste a sampled time history (values with a sample rate, or time and value columns) and get its frequency content: the amplitude spectrum by the fast Fourier transform, the power spectral density by Welch's method, the dominant frequency with its amplitude, and the mean, rms, peak, crest factor and kurtosis of the record. Frequencies are in hertz and times in seconds; the signal keeps the unit you name. Advanced mode adds a Butterworth filter, one integration or differentiation, and octave-band levels. Not for records above 32,768 samples.

  • Amplitude spectrum by FFT of any record length (no zero padding) and PSD by Welch's averaged periodograms, charted on linear or log axes

  • Five windows with their coherent gain and equivalent noise bandwidth applied, so a sine reads its true amplitude and noise its true density

  • Sample rate, duration, resolution, Nyquist frequency, rms, crest factor and Parseval's check as formula, numbers, answer

  • Butterworth filtering (zero-phase or causal), one integration or differentiation, peak table with half-power damping, octave-band levels

Signal Analysis

/

Record (frequency in Hz, time in s)







Analysis








Filter and Calculus (applied before the analysis)









×

Signal Analysis (FFT and PSD)

Method: the DFT, Windows and Their Corrections, Welch's PSD, Filtering, What It Assumes and Common Mistakes

What the tool does

It takes a signal sampled at a steady rate and shows which frequencies it contains: the amplitude of each sine (the amplitude spectrum) and, for random signals, the power per hertz (the power spectral density, PSD). Around that it reports the time-domain statistics, cleans the record with a detrend, a window and an optional Butterworth filter, and checks itself by recovering the rms of the record from its spectrum.

The idea: a record is a sum of sines that fit in it

A record of N samples taken fs times a second lasts T = N / fs seconds. The discrete Fourier transform (DFT) writes it as a sum of sines that complete a whole number of cycles in T: 0, 1, 2, … cycles, that is the frequencies 0, Δf, 2Δf, … with

Δf = fs / N = 1 / T   (frequency resolution)     fNyq = fs / 2   (Nyquist frequency, the highest one the samples can hold)

Each of these frequencies is one spectral line. A longer record gives finer lines; a faster sample rate gives a higher top frequency. Nothing else changes either of them.

Xk = Σn xn wn e−j 2π k n / N,   k = 0 … N/2

where wn is the window (all ones for the rectangular window). The tool computes Xk with a radix-2 fast Fourier transform when N is a power of two and with Bluestein's chirp algorithm otherwise, so every record length is transformed exactly as it is, with no zero padding.

Top: a sine with ten and a half cycles in the record, as sampled and multiplied by a Hann window that tapers both ends to zero. Bottom: its amplitude spectrum on a logarithmic scale for three windows. The rectangular window reads 0.65 at the nearest line and spreads the tone over every line; the Hann window reads 0.85 and falls off quickly; the flat top window reads 1.00 over a wider group of lines.
A tone that does not complete a whole number of cycles falls between two lines. Without a window it reads low and leaks into every line; a window trades a wider peak for less leakage, and the flat top window reads the amplitude correctly.

Amplitude spectrum

The single-sided amplitude of line k is

Ak = 2 |Xk| / Sw,    Sw = Σ wn

The factor 2 folds the negative frequencies onto the positive ones (the line at zero frequency, and the Nyquist line of an even N, are not doubled). Dividing by the window sum Sw instead of N undoes the amplitude the window removed; Sw / N is the window's coherent gain. Ak is the peak amplitude of the sine A sin(2π f t); its rms amplitude is A / √2.

Windows

The DFT treats the record as one period of a signal that repeats forever. If the two ends do not join smoothly, the jump spreads power over all lines (leakage). A window tapers the ends. The five offered here are sums of cosines, wn = a0 − a1 cos(2π n / N) + a2 cos(4π n / N) − …:

WindowCoefficients a0, a1, …Coherent gainNoise bandwidth, linesHalf-power width, linesLargest amplitude error between lines
Rectangular111.0000.886−36 %
Hann0.5, 0.50.51.5001.441−15 %
Hamming0.54, 0.460.541.3631.303−18 %
Blackman0.42, 0.5, 0.080.421.7271.644−12 %
Flat top0.21557895, 0.41663158, 0.277263158, 0.083578947, 0.0069473680.21563.7703.725−0.1 %

The equivalent noise bandwidth is ENBW = N Sww / Sw², with Sww = Σ wn², in lines: the width of the ideal rectangular filter that would collect the same noise power as one line. It is what turns an amplitude into a density. The rectangular, Hann and Hamming values agree with the table of Heinzel, Rüdiger and Schilling to the printed digits; the Blackman and flat top values are computed here. The flat top coefficients are those of the scipy library's window.

Between lines. For a narrow peak the tool fits the window's own transform through the largest line and its larger neighbor, which gives the frequency and the amplitude of the one steady tone that would produce those two lines. This is exact for a lone tone and approximate when another tone or noise sits within a few lines.

Power spectral density by Welch's method

A random signal has no amplitude at a frequency, only a density: power per hertz. From one transform the density at line k is

Gk = 2 |Xk|² / (fs Sww)

(again without the 2 at zero frequency and at Nyquist). One such estimate scatters by 100 % of its own value however long the record is. Welch's method cuts the record into K segments of L samples that overlap, detrends, windows and transforms each, and averages the K values of Gk. The resolution becomes fs / L and the scatter falls:

K = floor((N − Nov) / (L − Nov))     ν = 2K / cov     ε = √(2 / ν)

ν is the number of statistical degrees of freedom and ε the normalized random error (standard deviation over mean). Overlapped segments share samples, so they are not independent: cov = 1 + 2 Σj (1 − j/K) ρj, where ρj = (Σ wn wn+jD / Sww)² is the squared overlap correlation of two windows j steps of D = L − Nov samples apart. The true density lies between ν G / χ²0.95 and ν G / χ²0.05 with 90 % confidence, the χ² values being those of ν degrees of freedom.

Parseval's check

The power of the record is the same in time and in frequency. With the rectangular window, the sum of Gk Δf over all lines (equally, the sum of the squared rms line amplitudes) equals the mean square of the samples to rounding. With another window the sum equals the mean square of the windowed record divided by the window's own mean square, which is close to the plain mean square for a steady signal. The tool prints both rms values and their ratio.

Time-domain statistics

rms = √(Σ x² / N); peak = the largest absolute value; crest factor = peak / rms; kurtosis = m4 / m2², the fourth moment about the mean over the squared variance (3 for Gaussian noise, 1.5 for a sine, well above 3 for impacts).

Detrending, filtering and calculus

The order is fixed: detrend, filter, integrate or differentiate, then analyze.

  • Detrend: the mean, or the least-squares straight line, is subtracted from the record, and again from each Welch segment.
  • Butterworth filter of order n: the analog prototype with poles evenly spaced on the left half of the unit circle, moved to the cutoff (low-pass, high-pass) or the band (band-pass, 2n poles), then mapped to a digital filter by the bilinear transform with the cutoffs pre-warped, f → tan(π f / fs), and run as a cascade of second-order sections. The gain is 1/√2 (−3 dB) at each cutoff. Zero-phase filtering runs the cascade forward and then backward, with the ends padded by odd reflection and the sections started in their steady state: no delay, twice the attenuation in decibels (−6 dB at each cutoff). The causal option is one forward pass from rest.
  • Integrate once by the trapezoidal rule (acceleration to velocity), after which the chosen trend is removed again. Differentiate once by central differences.

Damping from the half-power width

A lightly damped resonance that rings down freely, or is driven by broadband noise, shows as a peak whose width between the two points at half power (0.707 of the peak amplitude) is Δfhp = 2 ζ fn. The tool therefore lists ζ = Δfhp / (2 f) for a peak, but only when the peak is at least four lines wide and three times the window's own half-power width; a narrower peak is a steady tone or an unresolved resonance.

Octave bands

Midband frequencies are 1000 × 100.3 i / b Hz with b = 1 for octave and b = 3 for one-third-octave bands, and each band reaches a factor 100.15 / b either side. The rms in a band is the square root of the sum of Gk Δf over the lines inside it. This is a sum of spectral lines, not a set of standard band filters.

What it assumes

  • The samples are evenly spaced. A two-column record with uneven spacing is resampled by straight lines at its median spacing, which is said in the results.
  • The measured signal held nothing above the Nyquist frequency (an anti-aliasing filter did its work before sampling). The tool cannot detect or remove aliasing.
  • For the amplitude spectrum: the signal is steady over the record (tones do not start, stop or drift).
  • For the PSD and its error: the signal is random and stationary, and the PSD is smooth across one resolution width.
  • The signal's unit is the one you name; nothing is converted.

When it misleads

  • Tones in a PSD. The height of a tone's peak in a PSD is its mean square divided by the noise bandwidth, so it changes with the segment length. Read tones from the amplitude spectrum and noise from the PSD.
  • Transients in an amplitude spectrum. A ring-down or an impact has a spectrum whose shape is meaningful and whose height depends on the record length. A tapering window can remove most of a transient that sits at the start of the record: use the rectangular window.
  • Short records. Two tones closer than about two lines appear as one. With few Welch segments the PSD is rough: the printed error says how rough.
  • Integration. Low-frequency noise and any offset are amplified by integration and become drift. High-pass filter first, and distrust the lowest few lines.
  • Half-power damping. The window, the resolution and the scatter of the estimate all widen a peak, so the damping read from a spectrum is an upper estimate.
  • Size. Records are limited to 32,768 samples to keep the page fast; a longer one is refused with a message, not silently shortened.

Common mistakes

  • Dividing the transform by N and forgetting the 2 of the single-sided spectrum: every amplitude comes out half as large.
  • Forgetting to divide by the window's coherent gain: with a Hann window every amplitude comes out half as large again.
  • Using the amplitude correction for noise or the noise correction for tones. Amplitudes divide by Sw; densities divide by fs Sww.
  • Expecting zero padding to improve resolution. It draws a smoother curve through the same information; only a longer record resolves closer tones.
  • Mixing peak, rms and peak-to-peak. A sine of peak amplitude 1 has an rms of 0.707 and a peak-to-peak value of 2.
  • Leaving the mean in. A large offset leaks from line 0 into its neighbors through the window and hides low-frequency content.
  • Sampling too slowly. A 70 Hz tone sampled 100 times a second appears at 30 Hz, and nothing in the samples can tell the difference.
  • Comparing PSD peaks taken with different resolutions, or quoting a PSD without its degrees of freedom.
  • Reading g²/Hz as g/Hz. The square root of the area under the PSD is the rms; the PSD itself is a squared quantity per hertz.

Next step

A PSD found here is the input of Random Vibration Response; a transient record goes to Shock Response Spectrum.




References

Heinzel, G., Rüdiger, A., and Schilling, R. (2002). Spectrum and Spectral Density Estimation by the Discrete Fourier Transform (DFT), Including a Comprehensive List of Window Functions and Some New Flat-Top Windows. Max-Planck-Institut für Gravitationsphysik (Albert-Einstein-Institut), Hannover.

Welch, P. D. (1967). "The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short, Modified Periodograms." IEEE Transactions on Audio and Electroacoustics, Vol. AU-15, No. 2, pp. 70–73.

Harris, F. J. (1978). "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform." Proceedings of the IEEE, Vol. 66, No. 1, pp. 51–83.

Bluestein, L. I. (1970). "A Linear Filtering Approach to the Computation of Discrete Fourier Transform." IEEE Transactions on Audio and Electroacoustics, Vol. AU-18, No. 4, pp. 451–455.

Butterworth, S. (1930). "On the Theory of Filter Amplifiers." Experimental Wireless and the Wireless Engineer, Vol. 7, pp. 536–541.

Bendat, J. S., and Piersol, A. G. (2010). Random Data: Analysis and Measurement Procedures, 4th ed. John Wiley and Sons, Hoboken, NJ.


DISCLAIMER: The methods and calculation on aNOWysis.com are provided as means to educate the reader. There is no warranty, expessed or implied, as to the relevance or accuracy of the methods or calculations. All calculations should be checked by a qualified analyst for appropriateness and accuracy. We will not be held liable for any damages, injuries or deaths caused by using methods or calculations from this site.