CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
simple_stat.h
Go to the documentation of this file.
1 #include <numeric>
2 #include <cmath>
3 
8 template< class CONT>
9 double stat_mean( const CONT & cont) {
10  double sum = accumulate (cont.begin(), cont.end(), 0.);
11  return sum / cont.size();
12 }
13 
19 template< class CONT>
20 double stat_RMS( const CONT & cont) {
21 
22  typename CONT::const_iterator i;
23 
24  int N = cont.size();
25  if (N > 1) {
26  double sum=0., sum2=0.;
27  for (i=cont.begin(); i!=cont.end(); i++) {
28  sum += *i;
29  sum2 += (*i) * (*i);
30  }
31  return sqrt( std::max( 0., (sum2 - sum*sum/N) / (N-1))) ;
32  }
33  else return 0.;
34 }
int i
Definition: DBlmapReader.cc:9
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
double stat_mean(const CONT &cont)
Definition: simple_stat.h:9
T sqrt(T t)
Definition: SSEVec.h:48
double stat_RMS(const CONT &cont)
Definition: simple_stat.h:20
#define N
Definition: blowfish.cc:9