[rrd-users] Re: Median calculations ?

Alex van den Bogaerdt alex at ergens.op.het.net
Wed Mar 15 01:19:33 MET 2006


On Tue, Mar 14, 2006 at 06:27:17PM +0100, Alex Prinsier wrote:
> No it's not the same. Consider these numbers: {50,1,2,3,4}. The average
> (50th percentile I believe is the same as average) = (50+1+2+3+4)/5 = 12.

Actually it is not.  I think the outcome would be 3.

code in rrd_graph.c:
                for (step=0;step < steps; step++) {
                    array[step]=data[step*src->ds_cnt];
                }
                qsort(array,step,sizeof(double),vdef_percent_compar);

                field = (steps-1)*dst->vf.param/100;
                dst->vf.val  = array[field];

Create an array of rates.
Sort that array.
Select field n/100

For the 50th percentile out of 5 array members:

Create array:          50,1,2,3,4
Sort array:            1,2,3,4,50
Compute (5-1)*50/100:  2  (zero based)
Select array member 2: 3


For an even number of array members this algorithm would select the
lower number, not the average around the middle.  So, for 6 array
members it would select member 2, not the average of member 2 and 3.

-- 
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list