cuserrnd
Continuous USER-defined-distribution RaNDom generator.
Syntax
aout cuserrnd kmin, kmax, ktableNum
iout cuserrnd imin, imax, itableNum
kout cuserrnd kmin, kmax, ktableNum
Initialization
imin -- minimum range limit
imax -- maximum range limit
itableNum -- number of table containing the random-distribution function. Such table is generated by the user. See GEN40, GEN41, and GEN42. The table length does not need to be a power of 2.
Performance
ktableNum -- number of table containing the random-distribution function. Such table is generated by the user. See GEN40, GEN41, and GEN42. The table length does not need to be a power of 2.
kmin -- minimum range limit
kmax -- maximum range limit
cuserrnd (continuous user-defined-distribution random generator) generates random values according to a continuous random distribution created by the user. In this case the shape of the distribution histogram can be drawn or generated by any GEN routine. The table containing the shape of such histogram must then be translated to a distribution function by means of GEN40 (see GEN40 for more details). Then such function must be assigned to the XtableNum argument of cuserrnd. The output range can then be rescaled according to the Xmin and Xmax arguments. cuserrnd linearly interpolates between table elements, so it is not recommended for discrete distributions (GEN41 and GEN42).
For a tutorial about random distribution histograms and functions see:
- D. Lorrain. "A panoply of stochastic cannons". In C. Roads, ed. 1989. Music machine. Cambridge, Massachusetts: MIT press, pp. 351 - 379.
Examples
Here is an example of the cuserrnd opcode. It uses the file cuserrnd.csd.
Its output should include lines like these:
i 1 time 0.00067: 53.14918
i 1 time 0.20067: 0.00000
i 1 time 0.40067: 0.00000
i 1 time 0.60067: 96.80406
i 1 time 0.80067: 94.20729
i 1 time 1.00000: 0.00000
i 1 time 1.20067: 86.13032
i 1 time 1.40067: 31.37096
i 1 time 1.60067: 70.35889
i 1 time 1.80000: 0.00000
i 1 time 2.00000: 49.18914
WARNING: Seeding from current time 2006647442
i 2 time 3.00067: 21.45002
i 2 time 3.20067: 44.32333
i 2 time 3.40067: 46.05420
i 2 time 3.60000: 0.00000
i 2 time 3.80067: 41.32175
i 2 time 4.00000: 0.00000
i 2 time 4.20000: 63.72019
i 2 time 4.40067: 0.00000
i 2 time 4.60067: 0.00000
i 2 time 4.80067: 0.00000
i 2 time 5.00000: 74.49330
See also
Credits
Author: Gabriel Maldonado
New in Version 4.16