# Verify FFT results without equation of waveform

I used python to convert the time-domain signal below into a frequency spectrum so that I can analyze the harmonics. To do this I used Python libraries, specifically numpy and called fft to get the spectrum. I now want to validate my results. I have x, y coordinates in Excel and the plot below. To validate, I know that I could try to compute the Fourier series myself. The problem that I'm having is that I can't actually figure out how to begin. I don't know the equation of the waveform below so I can't use the definition of the Fourier transform. Any ideas on how to do this manual validation (or any other suggestions on how to actually confirm whether my fft is correct) are extremely helpful.  • Is your plot attached the time domain waveform? If so can you attach your frequency domain results as well that you are trying to validate? Jul 29 at 22:03
• If you don't know the equation for it, how did you get it? Is it from a measurement, or handed to you by someone? Jul 29 at 22:43
• @TimWescott, I was given the signal. It's a disturbance signal taken from a recorder.
– Bern
Jul 30 at 2:53
• @DanBoschen, updated.
– Bern
Jul 30 at 2:54
• What exactly do you want to verify? Your code, the library, match between theory and praxis? Do you want to verify against the discrete or continuous Fourier Transform? Jul 30 at 13:21

You're fitting to measured data. The only way that I can see to make sure your fit is good is to analyze the FFT output, and reconstruct the waveform with a function, then see how that matches up to your captured data.

You're not capturing an integer number of periods. That will cause some spectral bleeding, because the bins don't match exactly. You probably want to window the captured data before you do the FFT -- this will make for slightly more, but cleaner, spectral bleeding.

From the waveform, it's a fundamental with a strong 5th-harmonic impressed on it -- that's consistent with what I see in your FFT.

You can hypothesize that the above is, indeed, what you're seeing. With that hypothosis, you can then identify the peaks and interpolate the actual frequency of the sine waves from them (alternately, if it's rotating or reciprocating machinery, just take the fundamental as being equal to the rotating or reciprocating frequency).

Then if you're still unsure if you're getting it right, reconstruct the signal from the phase & amplitude relationship.

I want to verify that the results from my python fft are correct.

Why? The Python FFT has been used millions of times and it's been unit thoroughly unit tested. What makes you think there us anything wrong by with it?

If this was some common waveform, I would do the transfer by hand. This would allow me to confirm that the amplitudes are correct, and at the right frequencies.

Then use some common waveforms to test your code. Just make sure that what you do "by hand" is an actual DFT (Digital Fourier Transform) and not a CFT (Continuous Fourier Transform). Your signals seem to be sparse sum of sine waves. You build some test cases from these. That's exactly what unit testing is about.

The problem is that because I don't have the equation of the waveform, I'm not sure how to hand calculate it. Any suggestions on how to verify are appreciated.

If you can't do it by hand, and if you don't trust the test cases that you can do by hand, you can only verify against a "known good" reference implementation.

For describing anything other than exact periods of pure sines, FFT is a suboptimal tool of choice, and requires careful interpretation. I advocate for time-frequency methods - see under Modulation Model vs Fourier Transform.

As for FFT, it implements DFT. One way to validate is to assert np.allclose against the naive implementation. As for conceptual validation - well, it's right to suspect DFT is broken, because it is, depending what we expect from it. Relevant article. Lastly, I advise visual studies over hammering out equations, and recommend this clip and DSP Guide.