]> git.treefish.org Git - phys/latlib.git/blobdiff - obs.hpp
...
[phys/latlib.git] / obs.hpp
diff --git a/obs.hpp b/obs.hpp
index 2501f141ae90a61d5ce0c8fb3a71a84a60512ad8..4d20bd6d901bff88f113d7a654a8fd87dca2ca4e 100644 (file)
--- a/obs.hpp
+++ b/obs.hpp
@@ -35,6 +35,7 @@ private:
   map<string,result> computations;
   
   void mean(const string& compid, vector< vector <double> > *meas, const int& ival);
+  void mean(const string& compid, vector< vector <int> > *meas, const int& ival);
 };
 
 
@@ -73,8 +74,24 @@ void obs<obstype>::mean(const string& compid, vector< vector<double> > *meas, co
   
   for(vector< vector<double> >::iterator measIt = meas->begin(); measIt != meas->end(); ++measIt)
     computations[compid].err += pow( (*measIt)[ival] - computations[compid].val, 2 );
-  computations[compid].err /= nmeas*(nmeas-1);
-  computations[compid].err = sqrt( computations[compid].err );  
+  computations[compid].err = sqrt( computations[compid].err ) / nmeas;  
+}
+
+template <typename obstype>
+void obs<obstype>::mean(const string& compid, vector< vector<int> > *meas, const int& ival)
+{
+  computations[compid].val = 0;
+  computations[compid].err = 0;
+  
+  int nmeas = meas->size();
+
+  for(vector< vector<int> >::iterator measIt = meas->begin(); measIt != meas->end(); ++measIt)
+    computations[compid].val += (*measIt)[ival];
+  computations[compid].val /= nmeas;
+  
+  for(vector< vector<int> >::iterator measIt = meas->begin(); measIt != meas->end(); ++measIt)
+    computations[compid].err += pow( (*measIt)[ival] - computations[compid].val, 2 );
+  computations[compid].err = sqrt( computations[compid].err ) / nmeas;
 }                               
     
 template <typename obstype>