Randomness:

Filter: - Create single random numbers
- Between zero and <number>
- Between -<number> and <number>
- Within a given range
- Test them multiple times with a do loop
- Collect the results in an array
- Seeding
- Histograms
- on Collections
- Arbitrary random distributions
- Random decisions
- Generating Collections of random numbers
- Random choice from Collections
- Randomize the order of a Collection
- Generate random numbers without duplicates
- Randomly group a Collection
- Random signal generators, i.e. UGens
- Random operators on signals
- UGens that generate random numbers once, or on trigger:
- Seeding
- UGens that generate random numbers on demand
- Random Patterns

As in any computer program, there are no "truly random" number generators in SC. They are pseudo-random, meaning they use very complex, but deterministic algorithms to generate sequences of numbers that are long enough and complicated enough to seem "random" for human beings. (i.e. the patterns are too complex for us to detect.)

If you start a random number generator algorithm with the same "seed" number several times, you get the same sequence of random numbers. (See example below, randomSeed)

You can seed a random generator in order to repeat the same sequence of random numbers:

See also Random Seed.

Demonstrate the various statistical distributions visually, with histograms:

Use a histogram to display how often each (integer) occurs in a collection of random numbers, :

A histogram for linrand:

A histogram for bilinrand:

A histogram for exprand:

And for sum3rand (cheap quasi-gaussian):

All of the single-number methods also work for (Sequenceable)Collections, simply by applying the given random message to each element of the collection:

An integral table can be used to create an arbitrary random distribution quite efficiently. The table building is expensive though. The more points there are in the random table, the more accurate the distribution.

`coin`

simulates a coin toss and results in true or false. 1.0 is always true, 0.0 is always false, 0.5 is 50:50 chance.

biased random decision can be simulated bygenerating a single value and check against a threshhold:

`choose`

: equal chance for each element.

Weighted choice:

`wchoose(weights)`

: An array of weights sets the chance for each element.

The probability argument sets the chance that two adjacent elements will be separated.

- PinkNoise
- WhiteNoise
- GrayNoise
- BrownNoise
- ClipNoise
- LFNoise0
- LFNoise1
- LFNoise2
- LFClipNoise
- LFDNoise0
- LFDNoise1
- LFDNoise3
- LFDClipNoise
- Dust
- Dust2
- Crackle
- TWChoose

Also see UGens>Generators>Stochastic in the Browse: UGens>Generators>Stochastic page.

Unary or binary random method produce a random value for each frame (not implemented in some cases). This can be used to implement tendency masks.

- Rand
- uniform distribution of float between (lo, hi), as for numbers.
- IRand
- uniform distribution of integer numbers.
- TRand
- uniform distribution of float numbers, triggered
- TIRand
- uniform distribution of integer numbers, triggered
- LinRand
- skewed distribution of float numbers, triggered
- NRand
- sum of n uniform distributions, approximates gaussian distr. with higher n.
- ExpRand
- exponential distribution
- TExpRand
- exponential distribution, triggered
- CoinGate
- statistical gate for a trigger
- TWindex
- triggered weighted choice between a list.

Like using randSeed to set the random generatorsfor each thread in sclang, you can choose which of several random generators on the server to use, and you can reset (seed) these random generators:

("Demand UGens")

see random patterns with analogous names

- Prand
- choose randomly one from a list ( list, numRepeats)
- Pxrand
- choose one element from a list, no repeat of previous choice
- Pwhite
- within range [<hi>, <lo>], choose a random value.
- Pbrown
- within range [<hi>, <lo>], do a random walk with a maximum <step> to the next value.
- Pgbrown
- geometric brownian motion
- Plprand
- Phprand
- Pmeanrand
- Pbeta
- Pcauchy
- Pgauss
- Ppoisson
- Pexprand
- Pwrand
- choose from a list, probabilities by weights
- Pshuf
- scramble the list, then repeat that order <repeats> times.
- Pwalk
`Pwalk( (0 .. 10), Prand([ -2,-1, 1, 2], inf));`

random walk.- Pfsm
- random finite state machine pattern, see its help file. see also MarkovSet in MathLib quark
- Pseed
- sets the random seed for that stream.

some basic examples

helpfile source: https://github.com/supercollider/supercollider/tree/3.13/HelpSource/Guides/Randomness.schelp

link::Guides/Randomness::

link::Guides/Randomness::