Charles Henry wrote:
On Sun, Mar 16, 2008 at 11:16 AM, Martin Peach martin.peach@sympatico.ca wrote:
(gaussianoise has occasional values that exceed [-1 ... 1], which I suppose is normal...white noise is always on [-1...1])
That's true. With the Box-Muller method, there is the log(~U1) term, but you can always just add a small value to U1, which will truncate your distribution. The size of the small value can be calculated to fit with any given threshold.
I think it's really because the Box-Muller method selects random numbers in pairs which map to points in a unit square on the plane, but then selects only those points which are inside the unit circle, something that the pd patch doesn't do (how to resample points in a dsp vector until they are in range?). The attached patch shows the straightforward way of doing it by simply selecting a random radius and angle and returning the resulting y coordinate as the random number. The results are always on [-1,1]. I don't think sin~ will be any slower than log~.
Martin
#N canvas 767 150 450 351 10; #X obj 86 2 noise~; #X obj 135 192 tabwrite~ bbb; #X obj 145 159 table bbb; #X obj 135 137 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 75 258 dac~; #X obj 274 43 noise~; #X obj 274 64 *~ 3.14159; #X obj 275 98 sin~; #X obj 85 115 *~; #X text 151 135 write to table; #X obj 84 193 *~; #X obj 32 30 vsl 15 128 0 1 0 0 empty empty empty 0 -9 0 10 -4034 -13381 -1 2000 1; #X text 89 80 random radius on [-1 , 1]; #X text 278 79 random angle on [-pi , +pi]; #X connect 0 0 8 0; #X connect 3 0 1 0; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 7 0 8 1; #X connect 8 0 1 0; #X connect 8 0 10 0; #X connect 10 0 4 0; #X connect 10 0 4 1; #X connect 11 0 10 1;