test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
simple_stat.h File Reference
#include <numeric>
#include <cmath>

Go to the source code of this file.

Functions

template<class CONT >
double stat_mean (const CONT &cont)
 
template<class CONT >
double stat_RMS (const CONT &cont)
 

Function Documentation

template<class CONT >
double stat_mean ( const CONT &  cont)

A trivial class computing the mean value of objects in any STL container.

Definition at line 9 of file simple_stat.h.

Referenced by TIBRing::checkPeriodicity().

9  {
10  double sum = accumulate (cont.begin(), cont.end(), 0.);
11  return sum / cont.size();
12 }
int cont
template<class CONT >
double stat_RMS ( const CONT &  cont)

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, bookConverter::max, N, and mathSSE::sqrt().

Referenced by PhiBorderFinder::PhiBorderFinder(), and RBorderFinder::RBorderFinder().

20  {
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
T sqrt(T t)
Definition: SSEVec.h:48
#define N
Definition: blowfish.cc:9
int cont