Oh no that's wrong isn't it :(
The log is necessary to keep the distribution normal, and the range is going to get wider the closer to zero the radius is allowed to get.
The attached patch has a scale adjustment...
Still I wonder what kind of distribution gaussianoise2 gives, it's not just white.

Martin


Martin Peach wrote:
Charles Henry wrote:
On Sun, Mar 16, 2008 at 11:16 AM, Martin Peach
<[EMAIL PROTECTED]> 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


------------------------------------------------------------------------

_______________________________________________
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

#N canvas 767 150 450 461 10;
#X obj 65 -59 noise~;
#X obj 135 192 tabwrite~ bbb;
#X obj 145 159 table bbb;
#X obj 135 137 bng 15 250 50 0 empty empty write 17 7 0 10 -4034 -13381
-13381;
#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 obj 84 193 *~;
#X obj 21 34 vsl 15 128 0 1 0 1 empty empty volume 0 -9 0 10 -4034
-13381 -13381 3800 1;
#X text 278 79 random angle on [-pi \, +pi];
#X obj 64 -38 abs~;
#X obj 64 23 ln~;
#X obj 64 77 sqrt~;
#X obj 64 46 *~ -2;
#X obj 64 -18 *~ 0.999;
#X obj 65 3 +~ 0.001;
#X text 103 77 random radius on [0 \, big];
#X obj 241 -14 -;
#X obj 230 -62 t b f;
#X msg 231 -41 1;
#X floatatom 241 8 5 0 0 0 - - -;
#X floatatom 230 -83 5 0 0 0 - - -;
#X obj 233 -105 hsl 128 15 0 1 0 1 empty empty scale -2 -8 0 10 -4034
-13381 -13381 2000 1;
#X obj 135 -101 metro 100;
#X obj 135 -121 tgl 15 0 empty empty plot 17 7 0 10 -4034 -13381 -13381
0 1;
#X connect 0 0 12 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 9 0;
#X connect 9 0 4 0;
#X connect 9 0 4 1;
#X connect 10 0 9 1;
#X connect 12 0 16 0;
#X connect 13 0 15 0;
#X connect 14 0 8 0;
#X connect 15 0 14 0;
#X connect 16 0 17 0;
#X connect 17 0 13 0;
#X connect 19 0 22 0;
#X connect 19 0 17 1;
#X connect 20 0 21 0;
#X connect 20 1 19 1;
#X connect 21 0 19 0;
#X connect 23 0 20 0;
#X connect 23 0 16 1;
#X connect 24 0 23 0;
#X connect 25 0 3 0;
#X connect 26 0 25 0;
_______________________________________________
PD-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to