Public Member Functions | Private Attributes | List of all members
cet::simple_stats Class Reference

#include <simple_stats.h>

Public Member Functions

 simple_stats () noexcept
 
 simple_stats (double x) noexcept
 
std::size_t size () const noexcept
 
double max () const noexcept
 
double min () const noexcept
 
double small () const noexcept
 
double sum () const noexcept
 
double sumsq () const noexcept
 
double mean () const noexcept
 
double range () const noexcept
 
double err_mean (std::size_t nparams=1u) const noexcept
 
double rms (std::size_t nparams=1u) const noexcept
 
double rms0 (std::size_t nparams=0u) const noexcept
 
double err_rms (std::size_t nparams=1u) const noexcept
 
void reset () noexcept
 
void sample (double) noexcept
 
template<class Iter >
void sample (Iter begin, Iter end) noexcept
 

Private Attributes

std::size_t n_
 
double min_
 
double max_
 
double small_
 
double sum_
 
double sumsq_
 

Detailed Description

Definition at line 25 of file simple_stats.h.

Constructor & Destructor Documentation

simple_stats::simple_stats ( )
noexcept

Definition at line 20 of file simple_stats.cc.

21  : n_(0u)
22  , min_(+std::numeric_limits<double>::infinity())
23  , max_(-std::numeric_limits<double>::infinity())
24  , small_(+std::numeric_limits<double>::infinity())
25  , sum_(0.0)
26  , sumsq_(0.0)
27 {
28  ;
29 }
std::size_t n_
Definition: simple_stats.h:85
simple_stats::simple_stats ( double  x)
noexcept

Definition at line 31 of file simple_stats.cc.

32  : n_(0u)
33  , min_(+std::numeric_limits<double>::infinity())
34  , max_(-std::numeric_limits<double>::infinity())
35  , small_(+std::numeric_limits<double>::infinity())
36  , sum_(0.0)
37  , sumsq_(0.0)
38 {
39  sample(x);
40 }
void sample(double) noexcept
list x
Definition: train.py:276
std::size_t n_
Definition: simple_stats.h:85

Member Function Documentation

double simple_stats::err_mean ( std::size_t  nparams = 1u) const
noexcept

Definition at line 59 of file simple_stats.cc.

60 {
61  return n_ == 0u ? std::numeric_limits<double>::quiet_NaN() :
62  rms(nparams) / std::sqrt(double(n_));
63 }
STL namespace.
double rms(std::size_t nparams=1u) const noexcept
Definition: simple_stats.cc:66
std::size_t n_
Definition: simple_stats.h:85
double simple_stats::err_rms ( std::size_t  nparams = 1u) const
noexcept

Definition at line 94 of file simple_stats.cc.

95 {
96  return n_ == 0u ? std::numeric_limits<double>::quiet_NaN() :
97  rms(nparams) / std::sqrt(double(2u * n_));
98 }
STL namespace.
double rms(std::size_t nparams=1u) const noexcept
Definition: simple_stats.cc:66
std::size_t n_
Definition: simple_stats.h:85
double cet::simple_stats::max ( ) const
inlinenoexcept

Definition at line 40 of file simple_stats.h.

41  {
42  return max_;
43  }
double simple_stats::mean ( ) const
noexcept

Definition at line 46 of file simple_stats.cc.

47 {
48  return n_ == 0u ? std::numeric_limits<double>::quiet_NaN() :
49  sum_ / double(n_);
50 }
std::size_t n_
Definition: simple_stats.h:85
double cet::simple_stats::min ( ) const
inlinenoexcept

Definition at line 45 of file simple_stats.h.

46  {
47  return min_;
48  }
double simple_stats::range ( ) const
noexcept

Definition at line 53 of file simple_stats.cc.

54 {
55  return max_ - min_;
56 }
void simple_stats::reset ( )
noexcept

Definition at line 104 of file simple_stats.cc.

105 {
106  *this = simple_stats();
107 }
simple_stats() noexcept
Definition: simple_stats.cc:20
double simple_stats::rms ( std::size_t  nparams = 1u) const
noexcept

Definition at line 66 of file simple_stats.cc.

67 {
68  if (n_ <= nparams)
69  return std::numeric_limits<double>::quiet_NaN();
70 
71  double diff = sumsq_ / double(n_) - square(mean());
72  if (diff < 0.0)
73  return 0.0;
74 
75  double factor = double(n_) / double(n_ - nparams);
76  return std::sqrt(factor * diff);
77 }
double mean() const noexcept
Definition: simple_stats.cc:46
constexpr T square(T x)
Definition: pow.h:21
std::size_t n_
Definition: simple_stats.h:85
double simple_stats::rms0 ( std::size_t  nparams = 0u) const
noexcept

Definition at line 80 of file simple_stats.cc.

81 {
82  if (n_ <= nparams)
83  return std::numeric_limits<double>::quiet_NaN();
84 
85  double diff = sumsq_ / double(n_);
86  if (diff < 0.0)
87  return 0.0;
88 
89  double factor = double(n_) / double(n_ - nparams);
90  return std::sqrt(factor * diff);
91 }
std::size_t n_
Definition: simple_stats.h:85
void simple_stats::sample ( double  x)
noexcept

Definition at line 110 of file simple_stats.cc.

111 {
112  ++n_;
113  min_ = std::min(x, min_);
114  max_ = std::max(x, max_);
116  sum_ += x;
117  sumsq_ += square(x);
118 }
constexpr T square(T x)
Definition: pow.h:21
T abs(T value)
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
list x
Definition: train.py:276
std::size_t n_
Definition: simple_stats.h:85
template<class Iter >
void cet::simple_stats::sample ( Iter  begin,
Iter  end 
)
inlinenoexcept

Definition at line 78 of file simple_stats.h.

79  {
80  for (; begin != end; ++begin)
81  sample(*begin);
82  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void sample(double) noexcept
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::size_t cet::simple_stats::size ( ) const
inlinenoexcept

Definition at line 35 of file simple_stats.h.

36  {
37  return n_;
38  }
std::size_t n_
Definition: simple_stats.h:85
double cet::simple_stats::small ( ) const
inlinenoexcept

Definition at line 50 of file simple_stats.h.

51  {
52  return small_;
53  }
double cet::simple_stats::sum ( ) const
inlinenoexcept

Definition at line 55 of file simple_stats.h.

56  {
57  return sum_;
58  }
double cet::simple_stats::sumsq ( ) const
inlinenoexcept

Definition at line 60 of file simple_stats.h.

61  {
62  return sumsq_;
63  }

Member Data Documentation

double cet::simple_stats::max_
private

Definition at line 86 of file simple_stats.h.

double cet::simple_stats::min_
private

Definition at line 86 of file simple_stats.h.

std::size_t cet::simple_stats::n_
private

Definition at line 85 of file simple_stats.h.

double cet::simple_stats::small_
private

Definition at line 86 of file simple_stats.h.

double cet::simple_stats::sum_
private

Definition at line 87 of file simple_stats.h.

double cet::simple_stats::sumsq_
private

Definition at line 87 of file simple_stats.h.


The documentation for this class was generated from the following files: