# [PD] variance from mapping library

Mathieu Bouchard matju at artengine.ca
Mon Mar 23 20:56:33 CET 2009

```On Mon, 23 Mar 2009, cyrille henry wrote:

> the mapping lib is optimized to work with number from -1 to 1.
> do you still have error using this kind of number?

Well, yes, of course: because float precision is relative, this behaviour
would happen for any scale of number, except in case of underflow, but
then, in case of underflow, the result can't be accurate anymore anyway.

You can send simple repeated sequences to [mapping/variance] to show that
not only it can drift in the negative values almost endlessly, but it
doesn't even compute the variance of N values. This is because there is a
moving average of something involving another moving average. This makes a
global moving average of 2N-1 values instead of N, and then the window
isn't rectangular anymore, it's triangular, because different values are
counted different number of times depending on how old they are.

That's why I added extra zeroes in the messagebox. Remove them
one at a time and you'll see this second phenomenon in addition
to the first one.

#N canvas 425 84 450 300 10;
#X obj 83 33 tgl 15 0 empty empty empty 17 7 0 10 -24198 -1 -1 1 1;
#X obj 83 69 t b b;
#X obj 83 107 f;
#X obj 83 126 nbx 12 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10
-225271 -1 -1 -0.000188258 256;
#X obj 83 50 metro 1;
#X msg 113 88 1 \, 1 \, 0 \, 0 \, 0 \, 0 \, 0 \, 0 \, 0 \, 0 \, 0;
#X obj 114 107 variance 5;
#X connect 0 0 4 0;
#X connect 1 0 2 0;
#X connect 1 1 5 0;
#X connect 2 0 3 0;
#X connect 4 0 1 0;
#X connect 5 0 6 0;
#X connect 6 0 2 1;

_ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec
```

More information about the Pd-list mailing list