Gaussian distribution

Apr 14, 2010 at 9:31pm

Gaussian distribution

Hi there,

Is there anyone who has a version of Tristan Jehan’s gauss[x] object for OSX? Can only find a PPC version. Or does anyone know of any other objects than can calculate a gaussian distribution?

Thanks!

#49780
Apr 14, 2010 at 10:37pm

Hi,

[mxj gaussian]

#178752
Apr 14, 2010 at 10:40pm

[lp.norm] from Litter pro.

#178753
Apr 14, 2010 at 11:02pm

Apart from using existing objects it’s fairly easy to create random numbers with normal distribution, simply by adding together uniformly distributed random numbers. For a true gaussian distribution you’d have to add together infinitely many numbers, but you can already get good results with a few iterations (usually 12 are used, which gives you some nice round numbers to work with).

So simply generate 12 uniformly distributed random numbers between 0 and 1, add them together, subtract 6 (= half of 12) and you’ll have normally distributed random numbers (but with a limited range of -6 to 6: This limited range won’t matter in practice however, since more than 99% of all normally distributed numbers will be within +-3 times the standard deviation anyways, which will be 1 here). If you want you can multiply this result by your desired standard deviation (which will also increase the range limit, so no worries there), then add your desired mean to it.

In Max, the following will produce a random, approximatively normally distributed number with standard deviation 1 and mean 0:

– Pasted Max Patch, click to expand. –
#178754
Apr 15, 2010 at 7:48am

@Szrp – There’s a much better way to generate gaussian distribution random numbers- by using the Box-Muller transform:

http://en.wikipedia.org/wiki/Box–Muller_transform

It’s possible to implement this in max – I did so several years ago, but I don’t have the patch to hand – anyway – if anyone wishes to do this they could implement it fairly easily using native max objects of in java etc.

Regards

Alex

#178755
Apr 15, 2010 at 11:02am

Ah, yes. I admit, I didn’t really study the issue. I just still remembered this very simple algorithm, which is quickly implemented and works well enough for most cases (I think it’s mentioned in the Dodge/Jerse Computer Music book, which is probably where I remember it from). I’m sure there are much better methods.

#178756
Apr 15, 2010 at 5:46pm

Thanks for the help guys!
I’m Actually not using it to generate random numbers, but to compare two audio signals by making a gaussian distribution of their FFT output. But I’ll look into your suggestions and give it a go,

#178757
Apr 15, 2010 at 8:58pm

 
[   expr (sqrt(-2.*ln(1-((random(0,32767))*(1./32767)))))*(cos(((random(0,32767))*(1./32767.))*6.283185307))   ]

save as [110.gaussian]

-110
 

#178758

You must be logged in to reply to this topic.