3 # The latest update : %G% at %U%
5 #%Z% eosMathStatistics ver %I%
8 #%Z% Usage : eosMathStatistics
12 static char __sccs_id[] = "%Z%eosMathStatistics ver%I%; Date:%D% %Z%";
14 #include "../inc/eosMath.h"
20 eosMathSorting(double* v, int n)
24 for(i=0; i<n-1; i++) {
25 for(j=0; j<n-1; j++) {
36 eosMathMedian(double* v, int n)
41 tmp = memoryAllocate(sizeof(double)*n, "in eosMathMedian");
45 eosMathSorting(tmp, n);
47 med = (tmp[n/2-1]+tmp[n/2])/2.0;
58 eosMathAverage(double* v, int n)
70 eosMathStddev(double* v, double mean, int n)
76 sum += SQR(v[i]-mean);
87 eosMathTrimmedAverage(double* v, int n, double trim)
97 nn = (int)(n*(1-trim*2)+0.5);
98 iStart = (int)(n*trim+0.5) ;
100 tmp = memoryAllocate(sizeof(double)*n, "in eosMathMedian");
101 tmp2 = memoryAllocate(sizeof(double)*nn, "in eosMathMedian");
105 eosMathSorting(tmp, n);
107 for(i=0; i<nn; i++) {
108 tmp2[i] = tmp[i+iStart];
110 avg = eosMathAverage(tmp2, nn);
120 eosMathHodgesLehmannEstimator(double* v, int n)
129 tmp = memoryAllocate(sizeof(double)*nn, "in eosMathMedian");
134 tmp[k] = (v[i] + v[j])/2.0;
138 eosMathSorting(tmp, nn);
141 avg = (tmp[nn/2-1]+tmp[nn/2])/2.0;