How to generate band-limited random noise with flat spectrum?

1.4k views Asked by At

How can I generate 500 ms worth of noise sampled at 1280 Hz, with a flat frequency distribution between 0.1 - 640 Hz and normally distributed amplitude values?

See the screenshot below for an illustration of the desired output.

Timeplot of waveform, frequency distribution, and histogram of amplitudes

1

There are 1 answers

0
Jonathan H On BEST ANSWER

The parameters of your question make the answer trivial:

  • 640 Hz is exactly half of 1280 Hz, so this is the highest frequency (Nyquist) in the Fourier decomposition;
  • 0.1 Hz is way below 1 / 500ms = 2Hz, which is the frequency resolution of your Fourier decomposition, and therefore the lowest positive frequency you can control.

So in your case, the "band-limited" constraint is trivial, and you can simply generate the desired noise with:

duration  = 500e-3;
rate      = 1280;
amplitude = 500;

npoints   = duration * rate;
noise     = amplitude * randn( 1, npoints ); % normally distributed white noise
time      = (0:npoints-1) / rate;

However, more generally, generating noise in a specific frequency band with constraints on spectrum shape (eg flat) and value statistics (eg normally distributed) can be difficult. There are two simple approximations I can think of:

  • Working in the time-domain, first enforcing constraints on value statistics by drawing from the distribution of choice, and then filtering the resulting signal using a band-pass FIR filter for example. For this approximation, note that the filter will also affect the distribution of values, and so in general your constraints on value statistics will be poorly met unless you design the filter very carefully.
  • Working backwards from the Fourier domain, first enforcing constraints on the amplitude coefficients, taking random noise for the phase, and using an inverse transform to come back to the time-domain. For this approximation, note that the phase distribution will affect the temporal distribution of values in non-trivial ways, depending on the amplitude constraints, and that if your sampling rate is much larger than your frequency cutoff, you might need to enforce constraints on harmonic amplitudes as well in order to avoid artefacts.