rand
Output is a controlled random number series between -amp and +amp
Syntax
Initialization
iseed (optional, default=0.5) -- a seed value for the recursive pseudo-random formula. A value between 0 and 1 will produce an initial output of kamp * iseed. A value greater than 1 will be seeded from the system clock. A negative value will cause seed re-initialization to be skipped. The default seed value is .5.
isel (optional, default=0) -- if zero, a 16-bit number is generated. If non-zero, a 31-bit random number is generated. Default is 0.
ioffset (optional, default=0) -- a base value added to the random result. New in Csound version 4.03.
Performance
kamp, xamp -- range over which random numbers are distributed.
ares, kres -- Random number produced.
The internal pseudo-random formula produces values which are uniformly distributed over the range kamp to -kamp. rand will thus generate uniform white noise with an R.M.S value of kamp / root 2.
The value ares or kres is within is a half-closed interval which contains -xamp, but never contains +xamp.
Examples
Here is an example of the rand opcode. It uses the file rand.csd.
The example will produce the following output:
i 1 time 0.00067: 50.00305
i 1 time 0.50000: 62.71362
i 1 time 1.00000: -89.31885
WARNING: Seeding from current time 472230558
i 2 time 2.00067: -70.65735
i 2 time 2.50000: 69.15283
i 2 time 3.00000: -48.79761
See also
Random (Noise) Generators, randh, randi
Credits
Thanks to a note from John ffitch, I changed the names of the parameters.