7
$\begingroup$

I need a time series of pink noise. How can I generate pink noise using Mathematica?

$\endgroup$
  • 1
    $\begingroup$ if you have v11 look at AudioGenerator $\endgroup$ – george2079 Jun 19 '17 at 15:43
  • $\begingroup$ @george2079 That generates audio, is it possible to extract the time series? $\endgroup$ – C. E. Jun 19 '17 at 15:52
  • 1
    $\begingroup$ Never heard of pink noise. Could you provide some links so we know exactly what definition you are using? Also, show us what you tried. It will make it easier to help you. $\endgroup$ – ivbc Jun 19 '17 at 16:06
  • 1
    $\begingroup$ @ivbc Thanks. Look here:en.wikipedia.org/wiki/Pink_noise Now I am trying to use entropy to analysis the complexity of white noise and pink noise(1/f).These pink-like noises occur widely in nature. First, I need generating a time series of pink noise. $\endgroup$ – Julian Jun 19 '17 at 16:16
  • 1
    $\begingroup$ @ivbc I just find it: "The 1/f noise is generated as follows: we start with uniformly distributed white noise, calculate the fast Fourier transform (FFT), and after imposing a 1/f distribution on the power spectrum, we calculate the inverse FFT. " $\endgroup$ – Julian Jun 19 '17 at 16:40
9
$\begingroup$

The approach below is still somewhat brute-force, but it was greatly improved by Carl Woll's suggestion to look into AudioData, which was the link I was missing here.

It works to generate a pink noise set using the output of AudioGenerator. you should be able to adapt the code to arbitrary sampling frequency and data length:

audio = AudioGenerator["Pink"]

data = Transpose@{
    Range[0, 1 - 1/44100, 1/44100.], 
    AudioData[audio]
  };

ListPlot[data, Frame -> True, Axes -> False]

Mathematica graphics

$\endgroup$
  • $\begingroup$ For data extraction, look at AudioData $\endgroup$ – Carl Woll Jun 19 '17 at 16:37
  • $\begingroup$ @MacroB Thanks a lot. It seems work well. $\endgroup$ – Julian Jun 19 '17 at 16:39
  • $\begingroup$ @CarlWoll Thank you! I was looking for that function exactly, and somehow I overlooked the link right there at the bottom of the documentation page for Audio :-( Is there a way to extract the timing information as well, or is that simply recreated based on sampling frequency? $\endgroup$ – MarcoB Jun 19 '17 at 16:41
  • $\begingroup$ @Julian You're welcome. I have modified the code to use AudioData, which is definitely more elegant, thanks to Carl's suggestion. That should look a little better and probably be faster. $\endgroup$ – MarcoB Jun 19 '17 at 16:42
  • $\begingroup$ For sample rate, use AudioSampleRate $\endgroup$ – Carl Woll Jun 19 '17 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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