Forums > MaxMSP

Biased Random

July 3, 2009 | 6:56 pm

Hi I am looking for some way to create a biased random number generator. For example If I have a random object that selects numbers from 0-100 I would like to have it pick between 1-10 the majority of the time. Does anything exist that does this?

Thanks,Mike.


July 3, 2009 | 7:07 pm

I don’t know, but something doesn’t have to exist, since it’s easy to build: you could just run the output of [random] into a [function] and draw the distribution function yourself.


July 3, 2009 | 7:41 pm

or just use a table with the weighted values in y. Check the help file on the behaviour of table when sent a bang

pa



Eli
July 3, 2009 | 8:04 pm

There are many different types of probability curves, (look up "different types of distributions" on Google) some that centralize around a particular range of numbers, and some that are "skewed", like the type that you describe, with the numbers "1-10" showing up more than 11-100.


July 3, 2009 | 8:24 pm

Thanks guys. Table seems to do exactly what I need.

Much appreciated. MIke.


July 4, 2009 | 2:22 pm
Mikelib wrote on Fri, 03 July 2009 20:56
Hi I am looking for some way to create a biased random number generator. For example If I have a random object that selects numbers from 0-100 I would like to have it pick between 1-10 the majority of the time. Does anything exist that does this?

You may want to take a look at the Litter Power package. It has implementations of every random number distribution known to mankind(*), possibly more than you want to know about.

The Litter Starter Pack (free) contains Bernoulli, Linear and Gaussian (normal) distributions, as well as a "flat" random number generator that is more reliable than the standard [random] object. It also has a nifty I Ching implementation.

The Litter Pro Bundle adds Poisson, Arc-sine & Beta, Chi-square, Cauchy, Exponential, Gamma, log-normal, Weibull and Pareto distributions as well as a family of high-quality correlated noise generators (pink, brown, black, etc.) And much, much more.

If you are serious about random numbers and noise, you ought to take a look at Litter Power.

You will probably find that a linear distribution from the Starter Pack (scaled to the range 1-100) will do what you want quite nicely. You can get finer control with the ‘Pro’ Beta-distribution.

Please note that the free Litter Starter Pack is much more friendly in a Max-4 world. The objects actually do work with Max 5, but there are a large number of cosmetic warnings and some issues with the help files. The Pro Bundle is fully Max 5-compatible.

Hope this helps,
Peter

PS: (*) In interest of full disclosure, Wikipedia actually lists a few highly exotic distributions that are not directly implemented in Litter Power. Wikipedia is bigger than mankind.-)


Viewing 6 posts - 1 through 6 (of 6 total)