36#include <itpp/itexports.h>
72 if (s < _min) _min = s;
73 if (s > _max) _max = s;
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;}
141 return std::exp(std::log(
static_cast<double>(
prod(
v))) /
v.
length());
148 return std::exp(std::log(
static_cast<double>(
prod(
prod(m))))
149 / (m.rows() * m.cols()));
162ITPP_EXPORT
double norm(
const cvec &v);
170 E +=
sqr(
static_cast<double>(
v[
i]));
176ITPP_EXPORT
double norm(
const cvec &v,
int p);
184 E += std::pow(
fabs(
static_cast<double>(
v[
i])),
static_cast<double>(p));
186 return std::pow(E, 1.0 / p);
190ITPP_EXPORT
double norm(
const cvec &v,
const std::string &s);
196 it_assert(s ==
"fro",
"norm(): Unrecognised norm");
200 E +=
sqr(
static_cast<double>(
v[
i]));
213ITPP_EXPORT
double norm(
const mat &m,
int p = 2);
223ITPP_EXPORT
double norm(
const cmat &m,
int p = 2);
226ITPP_EXPORT
double norm(
const mat &m,
const std::string &s);
229ITPP_EXPORT
double norm(
const cmat &m,
const std::string &s);
233ITPP_EXPORT
double variance(
const cvec &v);
240 const T *p =
v._data();
243 for (
int i = 0;
i <
len;
i++, p++) {
306ITPP_EXPORT
double moment(
const vec &x,
const int r);
336ITPP_EXPORT
double skewness(
const vec &x);
int size() const
Returns the number of data elements in the array object.
int length() const
Returns the number of data elements in the array object.
A class for sampling a signal and calculating statistics.
int _n_zeros
Number of zero samples.
int _n_overflows
Number of reported overflows.
virtual void sample(const double s, const bool overflow=false)
Register a sample and flag for overflow.
double _max
Maximum sample.
double sqr_sum() const
Squared sum of all samples.
double _sqr_sum
Squared sum of all samples.
double avg() const
Average over all samples.
vec histogram() const
Histogram over all samples (not implemented yet)
int n_zeros() const
Number of zero samples.
virtual ~Stat()
Destructor.
int n_samples() const
Number of samples.
double sigma() const
Standard deviation of all samples.
int _n_samples
Number of samples.
double _sum
Sum of all samples.
double _min
Minimum sample.
virtual void clear()
Clear statistics.
Stat()
Default constructor.
double min() const
Minimum sample.
int n_overflows() const
Number of reported overflows.
double sum() const
Sum of all samples.
double max() const
Maximum sample.
Elementary mathematical functions - header file.
#define it_assert(t, s)
Abort if t is not true.
T sum(const Vec< T > &v)
Sum of all elements in the vector.
T prod(const Vec< T > &v)
The product of all elements in the vector.
T max(const Vec< T > &v)
Maximum value of vector.
vec sqr(const cvec &data)
Absolute square of elements.
double moment(const vec &x, const int r)
Calculate the central moment of vector x.
double energy(const Vec< T > &v)
Calculate the energy: squared 2-norm. energy(v)=sum(abs(v).^2)
bool within_tolerance(double x, double xref, double tol=1e-14)
Return true if the input value x is within the tolerance tol of the reference value xref.
double kurtosis(const vec &x)
Calculate the kurtosis of the input vector x.
double skewness(const vec &x)
Calculate the skewness excess of the input vector x.
double kurtosisexcess(const vec &x)
Calculate the kurtosis excess of the input vector x.
double geometric_mean(const Vec< T > &v)
The geometric mean of a vector.
double norm(const cvec &v)
Calculate the 2-norm: norm(v)=sqrt(sum(abs(v).^2))
double median(const Vec< T > &v)
The median.
double variance(const cvec &v)
The variance of the elements in the vector. Normalized with N-1 to be unbiased.
double mean(const vec &v)
The mean value.
Matrix Class Definitions.
Various functions on vectors and matrices - header file.
Minimum and maximum functions on vectors and matrices.
bin abs(const bin &inbin)
absolute value of bin