41std::complex<double>
mean(
const cvec &
v)
58 return sum(
sum(m)) / (m.rows()*m.cols());
61std::complex<double>
mean(
const cmat &m)
63 return sum(
sum(m)) /
static_cast<std::complex<double>
>(m.rows()*m.cols());
68 return static_cast<double>(
sum(
sum(m))) / (m.rows()*m.cols());
73 return static_cast<double>(
sum(
sum(m))) / (m.rows()*m.cols());
86double norm(
const cvec &
v,
int p)
90 E += std::pow(std::norm(
v[
i]), p / 2.0);
92 return std::pow(E, 1.0 / p);
95double norm(
const cvec &
v,
const std::string &)
105double norm(
const mat &m,
int p)
108 "norm(): Can only calculate a matrix norm of order 1 or 2");
121double norm(
const cmat &m,
int p)
124 "norm(): Can only calculate a matrix norm of order 1 or 2");
133double norm(
const mat &m,
const std::string &s)
135 it_assert(s ==
"fro",
"norm(): Unrecognised norm");
137 for (
int r = 0; r < m.rows(); ++r) {
138 for (
int c = 0;
c < m.cols(); ++
c) {
139 E += m(r,
c) * m(r,
c);
146double norm(
const cmat &m,
const std::string &s)
148 it_assert(s ==
"fro",
"norm(): Unrecognised norm");
150 for (
int r = 0; r < m.rows(); ++r) {
151 for (
int c = 0;
c < m.cols(); ++
c) {
152 E += std::norm(m(r,
c));
163 std::complex<double>
sum = 0.0;
164 const std::complex<double> *p =
v._data();
166 for (
int i = 0;
i <
len;
i++, p++) {
176 double m =
mean(x),
mr = 0;
182 for (
int j = 0;
j < n;
j++)
186 for (
int j = 0;
j < n;
j++)
187 mr += (x(
j) - m) * (x(
j) - m);
190 for (
int j = 0;
j < n;
j++)
191 mr += (x(
j) - m) * (x(
j) - m) * (x(
j) - m);
194 for (
int j = 0;
j < n;
j++) {
195 temp = (x(
j) - m) * (x(
j) - m);
201 for (
int j = 0;
j < n;
j++)
215 double k3 =
moment(x, 3) * n * n / (n - 1) / (n - 2);
217 return k3 / std::pow(
k2, 3.0 / 2.0);
226 double k2 =
m2 * n / (n - 1);
227 double k4 = (
m4 * (n + 1) - 3 * (n - 1) *
m2 *
m2) * n * n / (n - 1) / (n - 2) / (n - 3);
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.
#define it_assert(t, s)
Abort if t is not true.
T sum(const Vec< T > &v)
Sum of all elements in the vector.
bool svd(const mat &A, vec &S)
Get singular values s of a real matrix A using SVD.
T max(const Vec< T > &v)
Maximum value of vector.
double moment(const vec &x, const int r)
Calculate the central moment of 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 norm(const cvec &v)
Calculate the 2-norm: norm(v)=sqrt(sum(abs(v).^2))
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.
Miscellaneous statistics functions and classes - header file.
bin abs(const bin &inbin)
absolute value of bin
Definitions of Singular Value Decompositions.