#include <numeric>
#include <cmath>
Go to the source code of this file.
Functions | |
template<class CONT> | |
double | stat_mean (const CONT &cont) |
A trivial class computing the mean value of objects in any STL container. | |
template<class CONT> | |
double | stat_RMS (const CONT &cont) |
A simple class computing the R.M.S. |
double stat_mean | ( | const CONT & | cont | ) | [inline] |
double stat_RMS | ( | const CONT & | cont | ) | [inline] |
A simple class computing the R.M.S.
of objects in any STL container.
Definition at line 20 of file simple_stat.h.
References i, max, N, funct::sqrt(), and sum().
Referenced by PhiBorderFinder::PhiBorderFinder(), and RBorderFinder::RBorderFinder().
00020 { 00021 00022 typename CONT::const_iterator i; 00023 00024 int N = cont.size(); 00025 if (N > 1) { 00026 double sum=0., sum2=0.; 00027 for (i=cont.begin(); i!=cont.end(); i++) { 00028 sum += *i; 00029 sum2 += (*i) * (*i); 00030 } 00031 return sqrt( std::max( 0., (sum2 - sum*sum/N) / (N-1))) ; 00032 } 00033 else return 0.; 00034 }