On Mon, 25 Oct 2004, chun lee wrote:
On 24/10/04 12:59 pm, "Tim Blechmann" TimBlechmann@gmx.net wrote:
Just wondering, does the methods used in Pd's [noise~] and [random] the implementation of minimal standard/Lehmer RNG method? Or something similar?
see doc/5.reference/help-random.pd ... random and noise are using the same algorithm ...
Thanks, I forgot to check the help files, my bad;( In addition, I found the below info on RNG while I was search on net. http://www.sbc.su.se/~per/crng/seminar/rng5.html http://www.cs.virginia.edu/~jcc5t/classes/undergrad/simulation/random/rng.c
Some more info on the linear congruential method: the m can be anything (in Pd it's 1<<32 exactly, because it's faster). To have the longest possible period, where all numbers in the range are visited, i think the conditions are that a,b,m are all coprime. Since m is a power of two this just forces a,b to be odd, which they would have been anyway, and then the only condition left is that a,b are coprime, that is, gcd(a,b)=1. However you want to make it look random so you have to make a and b big enough values that looks like nothing you already know. (else, you see, a=0 b=1 would be a good candidate ;-)
Then it only looks vaguely random. Obviously, if it guarantees to visit all 1<<32 numbers before duplicates come, it's not very random. I once filled a 256*256 grid (or something) using QuickBASIC (that was long ago) and that algorithm, and I could see patterns in the filling process. What's important to make it look random is to carefully avoid putting it in a situation where the nonrandomness is exhibited (duh). In the case of [noise~] no-one has an ear fine enough to find that it's linear-congruential.
_____________________________________________________________________ Mathieu Bouchard -=- Montréal QC Canada -=- http://artengine.ca/matju