[PD-dev] RNG

Chris McCormick chris at mccormick.cx
Tue Aug 27 18:38:33 CEST 2002


I recommend the following BSD lisenced algorithm. It's fast and simple (does not require mod or divide) and it's got a period of 2^19937:
http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html
Unfortunately the original homepage with the c source is down at the moment, but i have the code lying around in my dev directory somewhere. The link above has C++ code only.
I implemented this on the gameboy advance and found it's randomness quite (qualitatively speaking) satisfactory.

The only restriction as far as i know is that the original inventors are credited.

Regards,

Chris.

On Tue, 27 Aug 2002 08:59:59 -0700
Miller Puckette <mpuckett at man104-1.ucsd.edu> wrote:

> Hi Krzysztof,
> 
> I've never carefully tested the RNG in Pd, just typed out two huge
> numbers with my eyes closed, and never read that part of Knuth...
> If there's a good, simple cross-platform random number generator I'd be
> happy to use it, but I wouldn't trust anything native to Windows.
> Finally I could find no better solution than to write my own, bad
> one.  I did listen to noise~ output (sounded OK), looked at its spectrum
> (looks mighty flat) and did a histogram on a "random 10" (got 10 roughly
> equal numbers).
> 
> I think I did the same thing in the original Max but by now it might be
> replaced with something better, I dunno...
> 
> cheers
> Miller
> 
> 
> On Tue, Aug 27, 2002 at 04:33:11PM +0200, Krzysztof Czaja wrote:
> > hi Miller and others,
> > 
> > as I have resumed cyclone hacking today (after a long break),
> > I would like to finish coding the 'random' family first.
> > 
> > Not being even close to an expert on random number generators,
> > I have borrowed the two used in the 'random' and 'noise~'
> > builtins.  Today, just in order to have a quick try, I have used
> > them to produce an input for the 'diehard' set of tests.  Now
> > I have three questions:
> > 
> > 1. Before I start learning how to correctly interpret all the
> > results -- have been such, or similar, or any kind of tests,
> > performed for the Pd rngs?
> > 
> > 2. Seeing that the one used in noise~ (d_osc.c) has suboptimal
> > period length (2^{30}), I wonder if this does matter for the
> > `whiteness' of the output, or does not?  (The multiplier
> > a = 435898247 fails the property of b = a - 1 being a multiple
> > of 4 -- this is in Knuth 3.2.1.2, at least in a Polish
> > translation:)
> > 
> > 3. Waiting for a return of our mac used for checking things in
> > max/msp, I am not able yet to check what kind of output max/msp
> > rng produces.  Any hint?
> > 
> > thanks,
> > Krzysztof
> > 
> > 
> > _______________________________________________
> > PD-dev mailing list
> > PD-dev at iem.kug.ac.at
> > http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-dev
> 
> _______________________________________________
> PD-dev mailing list
> PD-dev at iem.kug.ac.at
> http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-dev
> 


-- 
_________________________________
chris at mccormick.cx
http://www.mccormick.cx
http://www.sciencegirlrecords.com




More information about the Pd-dev mailing list