2 summary:: random values that follow a Gaussian Distribution
3 related:: Classes/Ppoisson
4 categories:: Streams-Patterns-Events>Patterns>Random
8 This pattern uses the Box-Muller transform to generate a gaussian distribution from uniformly distributed values: code::sqrt(-2 * log(1.0.rand)) * sin(2pi.rand)::
15 The mean of the distribution.
17 argument::standardDeviation
18 The spread of values around the mean.
21 Number of values produced.
28 a = Pgauss(0.0, 100, inf);
29 c = a.asStream.nextN(500);
30 w = Window.new("Pgauss", Rect(10, 10, 540, 800));
32 c.plot(bounds: Rect(10, 10, 520, 380), discrete: true, parent: w);
33 // a histogram of the values
34 c.histo(500).plot(bounds: Rect(10, 410, 520, 380), parent: w);
39 a = Pgauss(0.0, 10.0, inf);
40 c = a.asStream.nextN(500);
41 w = Window.new("Pgauss", Rect(10, 10, 540, 800));
43 c.plot(bounds: Rect(10, 10, 520, 380), discrete: true, parent: w);
44 // a histogram of the values
45 c.histo(500).plot(bounds: Rect(10, 410, 520, 380), parent: w);
51 SynthDef(\help_sinegrain,
52 { arg out=0, freq=440, sustain=0.05;
54 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
55 Out.ar(out, SinOsc.ar(freq, 0, env))
61 a = Pgauss(0.0, 1.0,inf).asStream;
64 Synth(\help_sinegrain, [\freq, a.next * 600 + 300]);