Gaussian distribution

tunglutti's icon

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!

ch's icon

Hi,

[mxj gaussian]

Chris Muir's icon

[lp.norm] from Litter pro.

Szrp's icon

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.

Max Patch
Copy patch and select New From Clipboard in Max.

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

AlexHarker's icon

@Szrp - There's a much better way to generate gaussian distribution random numbers- by using the 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

Szrp's icon

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.

tunglutti's icon

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,

Roman Thilenius's icon

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

save as [110.gaussian]

-110