1 #ifndef NPSTAT_STATACCUMULATOR_HH_
2 #define NPSTAT_STATACCUMULATOR_HH_
18 #include "geners/ClassId.hh"
38 inline unsigned long count()
const {
return count_;}
41 inline double min()
const {
return min_;}
44 inline double max()
const {
return max_;}
47 long double sum()
const;
64 inline double rangeDown()
const {
return stdev();}
65 inline double rangeUp()
const {
return stdev();}
109 template <
typename Numeric>
110 inline void accumulate(
const Numeric* values,
const unsigned long n)
115 for (
unsigned long i=0; i<n; ++i)
124 template<
typename ConvertibleToLongDouble>
129 const long double factor(
static_cast<long double>(r));
130 const double scale(factor);
132 sumsq_ *= factor*factor;
133 runningMean_ *= factor;
138 const double tmp(min_);
150 template<
typename ConvertibleToLongDouble>
153 const long double denom =
static_cast<long double>(r);
154 if (denom == 0.0L)
throw std::domain_error(
155 "In npstat::StatAccumulator::operator/=: "
161 template<
typename ConvertibleToLDouble>
170 template<
typename ConvertibleToLDouble>
194 {
return !(*
this == r);}
198 inline gs::ClassId
classId()
const {
return gs::ClassId(*
this);}
199 bool write(std::ostream& of)
const;
202 static inline const char* classname() {
return "npstat::StatAccumulator";}
203 static inline unsigned version() {
return 2;}
204 static void restore(
const gs::ClassId&
id, std::istream& in,
205 StatAccumulator* acc);
208 void recenter(
long double newCenter);
212 long double runningMean_;
215 unsigned long count_;
216 unsigned long nextRecenter_;
220 inline StatAccumulator mul2(
const double r)
const
223 inline StatAccumulator div2(
const double r)
const
226 inline StatAccumulator& imul2(
const double r)
227 {*
this *= r;
return *
this;}
229 inline StatAccumulator& idiv2(
const double r)
230 {*
this /= r;
return *
this;}
232 inline double sum2()
const {
return sum();}
234 inline double sumsq2()
const {
return sumsq();}
236 inline void accumulate(
const std::vector<double>& values)
237 {
if (!values.empty())
accumulate(&values[0], values.size());}
239 inline void accumulate(
const std::vector<float>& values)
240 {
if (!values.empty())
accumulate(&values[0], values.size());}
Definition: StatAccumulator.hh:33
StatAccumulator operator/(const ConvertibleToLDouble &r) const
Definition: StatAccumulator.hh:171
long double sumsq() const
void accumulate(const Numeric *values, const unsigned long n)
Definition: StatAccumulator.hh:110
double meanUncertainty() const
unsigned long count() const
Definition: StatAccumulator.hh:38
double location() const
Definition: StatAccumulator.hh:63
double min() const
Definition: StatAccumulator.hh:41
double noThrowMean(double valueIfNoData=0.0) const
double noThrowStdev(double valueIfNoData=0.0) const
void accumulate(const StatAccumulator &)
bool operator==(const StatAccumulator &r) const
void accumulate(const StatAccumulator &, double w)
double noThrowMeanUncertainty(double valueIfNoData=0.0) const
void accumulate(double value)
bool operator!=(const StatAccumulator &r) const
Definition: StatAccumulator.hh:193
StatAccumulator operator*(const ConvertibleToLDouble &r) const
Definition: StatAccumulator.hh:162
gs::ClassId classId() const
Definition: StatAccumulator.hh:198
StatAccumulator & operator/=(const ConvertibleToLongDouble &r)
Definition: StatAccumulator.hh:151
double max() const
Definition: StatAccumulator.hh:44
StatAccumulator operator+(const StatAccumulator &r) const
Definition: StatAccumulator.hh:179
StatAccumulator & operator*=(const ConvertibleToLongDouble &r)
Definition: StatAccumulator.hh:125
Definition: AbsArrayProjector.hh:14