00001 // QMcBeaver 00002 // 00003 // Constructed by 00004 // 00005 // Michael Todd Feldmann 00006 // and 00007 // David Randall "Chip" Kent IV 00008 // 00009 // Copyright 2000. All rights reserved. 00010 // 00011 // drkent@users.sourceforge.net mtfeldmann@users.sourceforge.net 00012 00013 #ifndef QMCSTATISTIC_H 00014 #define QMCSTATISTIC_H 00015 00016 #include <iostream> 00017 #include <string> 00018 #include <math.h> 00019 00020 #ifdef PARALLEL 00021 #include <mpi.h> 00022 #endif 00023 00024 using namespace std; 00025 00026 00031 class QMCStatistic 00032 { 00033 private: 00034 long double sum; 00035 long double sum2; 00036 long double sum3; 00037 long double sum4; 00038 long double weights; 00039 unsigned long nsamples; 00040 00041 public: 00047 QMCStatistic(); 00048 00049 00054 void zeroOut(); 00055 00056 00061 unsigned long getNumberSamples() const; 00062 00063 00068 double getAverage() const; 00069 00070 00075 double getVariance() const; 00076 00077 00082 double getStandardDeviation() const; 00083 00084 double getSkewness() const; 00085 double getKurtosis() const; 00086 00094 void newSample(long double s, long double weight); 00095 void quickSample(long double s, long double weight); 00096 00101 void operator = ( const QMCStatistic &rhs); 00102 00107 QMCStatistic operator + (const QMCStatistic &rhs); 00108 00114 void reWeight(double w); 00115 00122 void toXML(ostream& strm); 00123 00124 00131 bool readXML(istream& strm); 00132 00133 00137 friend ostream& operator << (ostream& strm, const QMCStatistic & rhs); 00138 00139 00140 #ifdef PARALLEL 00141 00142 private: 00147 static bool mpiTypeCreated; 00148 00149 00154 static void buildMpiType(); 00155 00160 static void buildMpiReduce(); 00161 00162 00167 static void Reduce_Function(QMCStatistic *in, QMCStatistic *inout, 00168 int *len, MPI_Datatype *dptr); 00169 00170 public: 00171 00175 static MPI_Datatype MPI_TYPE; 00176 00177 00182 static MPI_Op MPI_REDUCE; 00183 00184 #endif 00185 00186 }; 00187 00188 #endif