# Generating Pink Noise

I've generated some white noise in Excel by using the formula

$$2*\mathrm{Math.RAND}()-1$$

I would now like to create some pink noise. I believe this is done by applying some sort of filter to the white noise, but I can't figure out how to do this.

P.S. White noise has a flat spectral density, but in pink noise frequency spectrum falls off as $\frac{1}{frequency}$. Any help is much appreciated!

-

The terms "white noise" and "pink noise" are applied to noise that depends on a parameter. The equation you gave technically isn't noise at all--- it's a real number uniformly distributed between -1 and 1. But I will assume that you are calling the RAND function inside a routine, and that this routine is simulating some system in time, and every time step it adds the random number to the velocity or the acceleration in a differential equation. In this case, the RAND call becomes white noise in the short time-step limit.

It is easy to generate white-noise, because you don't need to know the previous values of the noise to get future values.

The pink noise with a 1/f spectrum is nonlocal, so you need to do an FFT on a long random sequence, divide by $\sqrt{f}$ and FFT back, as DarenW said. This requires you to store the entire sequence of random numbers in memory, and is very tedious. If you use a filter, it will be nonlocal in time, so you still need to store many random values to work with.

You can generate a non-pink version of colored noise by keeping a sum-variable s around in your program. Just let s=s+(2*RAND()-1) (but be careful--- this introduces a slight drift in s because RAND usually can return exactly zero internally, but never exactly 1. You can fix this by keeping a random sign variable around and subtracting the random quantity instead of adding when the sign is negative). The sum value s will have long-time correlations, and it's spectrum is a powerlaw that falls off like $1\over f^2$. Perhaps this will be sufficient for your needs--- it is certainly much easier numerically.

-
The problem with using the FFT version is you don't get the same phase-amplitude relationship as the sum-variable method. Since in nature there exists a real time dependency for many processes you will likely more closely simulate nature if you use the sum-variable method. Try doing both methods, take an FFT of the result, and plotting real versus imaginary (complex plane). You will see a big difference. – Paul S Feb 17 at 0:51

For pink noise, the power spectrum falls off as 1/f. Remember that power is amplitude squared. For an electrical signal, power is voltage across times current flowing through a load, and the current follows from Ohm's Law. It is possible to arrange resistors and capacitors as a low pass filter to make an approximation of pink noise, but it's not precise. (I have a schematic in my files somewhere. Nag me and I'll look for it.)

But your signal is a list of numbers in a computer - you are lucky! These numbers are like voltages. Take a Fourier transform (I don't know of Excel can do that) and you'll have amplitudes ordered by frequency. Divide each amplitude by the square root of its frequency. Then the inverse Fourier transform will give you a pink noise signal.

We use square roots because we want the power, which is amplitude squared, to be reduced by a factor of f. Of course, you may want to make an exception for zero frequency - just set its amplitude to zero, and maybe also the few lowest frequency amplitudes just avoid overflows or other trouble.

-
Lets say the displacement is x and I have 1000 sequential displacements (random numbers between -1 and 1). So if I take the Fourier Transform of this whole lot, that will give me the amplitudes ordered by frequency? Divide each by it's frequency, inverse FT and that's it? So am I right in thinking the challenge is finding a way to take a FT of a sequence of random numbers? – Lars Nov 12 '11 at 16:54
@Lars: just take a power of two sized collection of random numbers, and feed it to a standard FFT. You don't even need to do the first step because the Fourier transform of white noise is white noise--- just generate a power of two Gaussian distributed random numbers, arrange them to be in the centered frequency range $-\pi$ to $\pi$ divide by $\sqrt{f}$ and FFT. – Ron Maimon Nov 12 '11 at 22:18
@RonMaimon I now realise about not needing to generate the white noise in the first place. However, the intensity of pink noise decreases with frequency as 1/f. So can I not just create an array of numbers with amplitude falling off like so then Inverse FFT? Why would I need power of two Gaussian distributed random numbers? And what does that actually mean? Square the random numbers? Thanks for the help so far, by the way! – Lars Nov 14 '11 at 4:02
I think using the gaussian distributed random numbers means your pink noise will also be gaussian distributed. – endolith Nov 10 '15 at 19:27