Pages

Sunday, April 23, 2023

A Rainbow of Random

Last week I was talking to Steve and Nate (my father and brother), and they mentioned using white noise generators to help with sleeping. That made me think of a meeting I was in earlier in the week where someone mentioned that LIGO and LISA typically have red noise contaminating the measurements. That made me wonder: What does red noise (or other colors of noise) sound like?

First off, we need to talk about what it means for noise to have a particular color. In the context of light, color tells use the frequency of light: red light has lower frequency than blue light, and white light is a mixture of all frequencies. We can apply the same principle to frequencies of sound: more low frequencies is redder, and more high frequencies is bluer. We figure out the "color" of a dataset by taking its Fourier transform, and looking at where the peak frequency lies. White noise has an equal amount of power in all frequencies.

That's the theory, but how do we go about generating different noise colors? White noise is easy: Given some sampling rate, we generate uniformly distributed random numbers. Because these numbers are uncorrelated, they don't favor any frequency, and give a flat spectrum. We can "redden" that noise by giving each sample some dependance on the previous. This page suggests mixing each sample with part of the previous:

where x is the series of samples, w a series of white samples, and r a tuning parameter between 0 and 1, with 0 giving white noise, and 1 giving constant values. For blue noise, we want to do the opposite: sequential values should be as different as possible. To do that we can follow the method here: For each blue point we want to generate, we get several white points and pick the one furthest from a previous sample.

We still haven't gotten to what these different noises sound like though. For that, we can use Javascript's AudioContext, and pipe these sequences of values through your speakers. Below, you'll find a slider to control the color of the noise – For red noise, it represents the r from above, and for blue noise it represents how many samples ago to avoid. That technique isn't quite right, so for values above zero (which is the white noise point) there isn't a continuous transition. In the window above the slider, you can see the Fourier transform of the sound, with the frequency going left to right. Maybe not the most soothing sounds, but I hope it can give you some insight into the sort of problems scientists have to deal with.

Canvas not supported; please update your browser.

Red --- White --- Blue

No comments:

Post a Comment