COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/Stat.cpp
Go to the documentation of this file.
00001 #include <coopy/Stat.h>
00002 
00003 //using namespace std;
00004 //using namespace coopy::store;
00005 
00006 /*
00007 Stat Stat::normalize(const FloatSheet& sheet, 
00008                      int first, int last, float sc, bool modify) {
00009   Stat s;
00010   int hh = sheet.height();
00011   int ww = sheet.width();
00012   if (first==-1) first = 0;
00013   if (last==-1) last = ww-1;
00014   float tot = 0;
00015   float tot2 = 0;
00016   int ct = 0;
00017   for (int i=0; i<hh; i++) {
00018     for (int j=first; j<=last; j++) {
00019       float r = sheet.cell(j,i);
00020       tot += r;
00021       tot2 += r*r;
00022       ct++;
00023     }
00024   }
00025   if (ct==0) return s;
00026   float mean = tot;
00027   float dev = 1;
00028   mean /= ct;
00029   dev = tot2 / ct - mean*mean;
00030   if (dev<0) { 
00031     dev = 0; 
00032   } else {
00033     dev = sqrt(dev);
00034   }
00035   //printf("mean %g, dev %g\n", mean, dev);
00036   if (dev<sc) dev = sc;
00037   if (modify) {
00038     for (int i=0; i<hh; i++) {
00039       for (int j=first; j<=last; j++) {
00040         float r = sheet.cell(j,i);
00041         r = (r-mean)/dev;
00042         sheet.cell(j,i) = r;
00043       }
00044     }
00045   }
00046   s.mean = mean;
00047   s.stddev = dev;
00048   s.valid = true;
00049   return s;
00050 }
00051 
00052 */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines