random number generators following probability distributions?
Hi all, i need a generator of numbers following probabilities in a gaussian distribution, binomial and poisson. Before i do it myself is there some external out there?
to save others a few clicks:
Gaussian can be generated with a formula using two uniform deviates, as demonstrated by Roman and Samuel. The formula only produces the standard normal distribution: Gauss(0, 1). It’s not hard to map that to the general case with any mean and standard deviation, but lp.norm from Litter Power will do the grunt work for you.
Binomial and Poisson distributions aren’t quite so easy.
Litter Power actually implements four different algorithms for binomial (Bernoulli) distributions to get optimum performance depending on parameters (the simplest algorithm gets extremely CPU-intensive for some parameters). As well as using an industrial-strength core random number generator. (Those who’ve known me for a long time are probably expecting me to point out that the built in random() used in the formulae above isn’t a very reliable RNG, and I would be remiss in disappointing anyone.-)
The Litter Starter Pack gives you your (generalized) Gaussian and binomial distributions, and can be downloaded for free from the URL Chris gave (thanks, Chris!) The Starter Pack is currently really a Max4 collection, however a determined Maxer can get it to run on Max5 (but it’s not a lot of fun). The Litter Pro Bundle is Max5-savvy and also gets you Poisson, Arc-sine, Cauchy, logistic, log-normal, and another three-dozen distributions plus another dozen-and-a-half as MSP signals. It is a commercial product.
If all you want is the three named distributions, you might want to look at the "Classic" Litter Bundle, which implements these as abstractions. Also available at the same link, it is no longer actively maintained but the patchers ought to work just fine on Max5. Also free to download.
Fantastic help. Thanks so much i downloaded Litter Bundle and works great. :)