[PD] Box Muller Gaussian noise

Lawrence Joseph Lawrence.Joseph at mcgill.ca
Sun Mar 16 16:55:10 CET 2008


Hi,

> Could a stats mathematician please help me check this. (attached)
>
> I'm following the Box Muller formula for getting  a cheap Gaussian
> distribution (instead of adding up 12 sources a la central limit method).
>
> http://www.dspguru.com/howto/tech/wgn.htm
>
> Does this look right?

I agree that this method is better than adding up 12 uniform distributions, 
which is not only inefficient, but not that accurate.

Your implementation looks about right, it would get the X but not the Y part 
of the random normal generation.  I am not too sure about the multiplication 
by 0.5 at the very end, but maybe there is some pd related reason for that. 
It's not part of the usual formula, but would just have an effect on the 
scale of the distribution, not the shape.

> Also, I have no idea how to check the distribution.

My pd knowledge is a bit weak (still a relative beginner), but if you could 
sample from that stream of random numbers, save the samples into a file and 
plot a histogram, you could check for approximate normality that way.  There 
are free programs like R (http://www.r-project.org/) available that draw 
histograms and are available for all platforms, many others as well.

> It sounds the same as
> uniform noise and looks the same in the spectrograph? What gives?

In my experience, it is extremely hard to distinguish different 
distributions by ear if they are all used for random noise streams.  I teach 
statistics, and one year, trying to combine my music hobby with my work, 
tried to see if I could get students to recognize different distributions by 
their sounds...its very difficult if you just let them generate random 
noise.  Some composers like Xenakis used different distributions to control 
other parameters such as pitch choice, and there, over time, you might 
recognize say a uniform distribution of 12 tones from one using an 
approximate normal distribution discretized to these 12 tones, as some tones 
might be recognized as appearing more often than others.  That's just one 
simple example of random number to musical parameter function, of course.

> Do I need to average over a very long time or something to see any
> difference?

If you want to SEE the difference, you just need a few values from each 
distribution, plot histograms, and it will be obvious which is a normal, 
which is a uniform, or Poisson, etc.  However, to hear the difference is a 
trickier proposition.

I hope this helps,
Lawrence 





More information about the Pd-list mailing list