How to generate white noise?

I need some white noise, which I then can shape to have the required spectrum using filters. But how to I generate white noise?

I could do it using rand or randn:

noise1=rand(Int(1e6)).-0.5
noise2=randn(Int(1e6))

I get

using Statistics
julia> var(noise1)
0.08329181864907934

julia> var(noise2)
0.9997758048382285

If I would multiply noise1 with a factor, would the spectrum be the same as the spectrum of noise2?

1 Like

Yes, the same spectrum (mean spectral density) and even the same distribution in the Fourier domain in the limit as your signal length goes to infinity, by the central limit theorem (which just requires you to make the mean and variance the same — use (rand() - 0.5) * √12 to get a variance of 1).

3 Likes