36 #include <itpp/itexports.h> 
   68   virtual void sample(
const double s, 
const bool overflow = 
false) {
 
   72     if (s < _min) _min = s;
 
   73     if (s > _max) _max = s;
 
   74     if (overflow) _n_overflows++;
 
   75     if (s == 0.0) _n_zeros++;
 
   85   double avg()
 const {
return _sum / _n_samples;}
 
   87   double max()
 const {
return _max;}
 
   89   double min()
 const {
return _min;}
 
   92     double sigma2 = _sqr_sum / _n_samples - avg() * avg();
 
   93     return std::sqrt(sigma2 < 0 ? 0 : sigma2);
 
   98   double sum()
 const {
return _sum;}
 
  121 ITPP_EXPORT 
double mean(
const vec &v);
 
  123 ITPP_EXPORT std::complex<double> 
mean(
const cvec &v);
 
  125 ITPP_EXPORT 
double mean(
const svec &v);
 
  127 ITPP_EXPORT 
double mean(
const ivec &v);
 
  129 ITPP_EXPORT 
double mean(
const mat &m);
 
  131 ITPP_EXPORT std::complex<double> 
mean(
const cmat &m);
 
  133 ITPP_EXPORT 
double mean(
const smat &m);
 
  135 ITPP_EXPORT 
double mean(
const imat &m);
 
  158   return (
double)(invect[(invect.
length()-1)/2] + invect[invect.
length()/2]) / 2.0;
 
  162 ITPP_EXPORT 
double norm(
const cvec &v);
 
  169   for (
int i = 0; i < v.
size(); i++)
 
  170     E += 
sqr(static_cast<double>(v[i]));
 
  176 ITPP_EXPORT 
double norm(
const cvec &v, 
int p);
 
  183   for (
int i = 0; i < v.
size(); i++)
 
  184     E += 
std::pow(fabs(static_cast<double>(v[i])), 
static_cast<double>(p));
 
  190 ITPP_EXPORT 
double norm(
const cvec &v, 
const std::string &s);
 
  196   it_assert(s == 
"fro", 
"norm(): Unrecognised norm");
 
  199   for (
int i = 0; i < v.
size(); i++)
 
  200     E += 
sqr(static_cast<double>(v[i]));
 
  213 ITPP_EXPORT 
double norm(
const mat &m, 
int p = 2);
 
  223 ITPP_EXPORT 
double norm(
const cmat &m, 
int p = 2);
 
  226 ITPP_EXPORT 
double norm(
const mat &m, 
const std::string &s);
 
  229 ITPP_EXPORT 
double norm(
const cmat &m, 
const std::string &s);
 
  233 ITPP_EXPORT 
double variance(
const cvec &v);
 
  240   const T *p = v.
_data();
 
  241   double sum = 0.0, sq_sum = 0.0;
 
  243   for (
int i = 0; i < len; i++, p++) {
 
  248   return (
double)(sq_sum - sum*sum / len) / (len - 1);
 
  262   return (fabs(x -xref) <= tol) ? 
true : 
false;
 
  266 inline bool within_tolerance(std::complex<double> x, std::complex<double> xref, 
double tol = 1e-14)
 
  268   return (
abs(x -xref) <= tol) ? 
true : 
false;
 
  274   return (
max(
abs(x -xref)) <= tol) ? 
true : 
false;
 
  280   return (
max(
abs(x -xref)) <= tol) ? 
true : 
false;
 
  286   return (
max(
max(
abs(X -Xref))) <= tol) ? 
true : 
false;
 
  292   return (
max(
max(
abs(X -Xref))) <= tol) ? 
true : 
false;
 
  306 ITPP_EXPORT 
double moment(
const vec &x, 
const int r);
 
  336 ITPP_EXPORT 
double skewness(
const vec &x);
 
  385 #endif // #ifndef MISC_STAT_H