Soon I'll be conducting experiments in a wave facility (flume) for my MSc thesis. And I would like to analyse wave spectra (amplitude and energy density).

The time step (or 'accuracy') of the wave maker, is by default dt = 0.001 s.

The sampling frequency of the measurement instruments (wave gauges) is 100 Hz (previously 25 Hz).

I'll start with bichromatic waves, which can be more or less be treated as being deterministic. I would like to prevent spectral leakage as much as possible.

The fundamental frequency is different for different experiments: short waves with a wave period of around 2.5 s. The wave maker includes bound waves (subharmonics), with the wave period Tbound one over the difference frequency of the short waves in the bichromatic wave train.

So far, previous students have set the FFT length to a power of 2. From what I read this is not necessary with modern implementations of the FFT.

One example of a previous student:

Fs = 25 Hz,

N = D*Fs = 2^13 (power of 2)

This results in a duration of the experiment of D = N/Fs = 327.68 s

with a spectral resolution of df = 1/D = 0.00305175781 Hz.

To avoid spectral leakage, frequencies of all my wave components should be a multiple of this number if I am correct.

Since I've set my wave gauges at a sampling frequency 100 Hz, I'm wondering if it's fine to increase my duration to D = 1000 s, so N = 100*1000 and is not a power of 2.

The resulting spectral resolution is: df = 1/D = 0.001 Hz and I'll round the frequencies of all my wave components to a multiple of this number.


1 Answer 1


So, the best news first:

Nyquist is your friend! As long as your sampling rate is sufficiently high, all the information contained in a band-limited analog signal can be represented by the digitized signal.

In other words: you can't sample too fast, and even if the ratio of sampling rate and signal frequency is irrational, you don't lose information.

So, you can follow the sample first, ask questions later philosophy¹.

Then, yes, if you want your periodic signal to occupy singular bins in your DFT, the DFT length needs to be an integer multiple of your period. And yes, FFTs can nowadays be implemented with a lot less restricted lengths². Your $10^N = 2^N\cdot5^N$ certainly is covered by the FFTW.

I'd like to encourage you to not only consider the DFT as frequency estimator.

MUSIC is able to calculate the spectrum at arbitrary frequencies (ie. it's an algorithm that you can ask "hey, what's the amplitude at f=0.123141414288?") instead of giving you an frequency-uniform amplitude vector, and if you know that you're looking for a fixed number of "peaks" in the spectrum, ESPRIT might be your thing. The accuracy of these algorithms is not bound by an orthogonal basis of frequencies, but on your ability to estimate the signals autocorrelation – which you can increase by adding more observation.

So, maybe you'd want to do the following:

  • Apply the DFT to your signal to get a "rough idea" of where your energy is in frequency
  • use MUSIC to generate a (pseudo-)spectrum around these frequencies of interest with a very fine resolution
  • As soon as you know how many tones to expect in the spectrum, throw ESPRIT at the problem to find exactly that number of dominant frequencies in your signal

¹: I'll need to make "SDR: Sample first, ask questions later" t-shirts.

²: The FFTW documentation (as far as I know) doesn't really specify, but in a half-sentence claims that things work best for lengths that can be factorized into prime factors $\le7$; one of the papers quoted on the homepage somewhere mentioned you can also have up to two factors of 11 and one factor of 13 in there to get an optimized FFT. That info is from the back of my head, might be wrong or outdated, and even if totally wrong: an absolutely naive DFT done by a matrix-vector multiplication will not put an unbearable load on your PC.
So simply use the DFT lengths you need, unless the vectors you need to transforms are in the millions of values.
And, directly from the fftw.org home page: Arbitrary-size transforms. (Sizes with small prime factors are best, but FFTW uses O(N log N) algorithms even for prime sizes.)
So, assuming you're doing a $10^6$ transform, and FFTW couldn't do better than $\mathcal O(N\log N)$, that'd be in the order of millions of floating point operations per transform. Assuming that your PC is about 20 years old and can do let's say 10 Million of these per second – do you have to worry at all?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.