11 for(
int i = 0; i < dimension; ++i)
13 return mean / dimension;
18 return mean(v.data(), v.size());
23 return cov(v, v, dimension, dimension);
28 return var(v.data(), v.size());
34 const int &dimension1,
35 const int &dimension2) {
37 T meanV1 =
mean(v1, dimension1);
38 T meanV2 =
mean(v2, dimension2);
39 for(
int i = 0; i < dimension1; ++i)
40 cov += (v1[i] - meanV1) * (v2[i] - meanV2);
41 return cov / (dimension1 - 1);
46 return cov(v1.data(), v2.data(), v1.size(), v2.size());
52 const int &dimension1,
53 const int &dimension2) {
54 return cov(v1, v2, dimension1, dimension2)
55 / (std::sqrt(
var(v1, dimension1)) * std::sqrt(
var(v2, dimension2)));
60 return corr(v1.data(), v2.data(), v1.size(), v2.size());
63#define STATISTICS_SPECIALIZE(TYPE) \
64 template TYPE Statistics::mean<TYPE>(TYPE const *, int const &); \
65 template TYPE Statistics::mean<TYPE>(std::vector<TYPE> const &); \
66 template TYPE Statistics::var<TYPE>(TYPE const *, int const &); \
67 template TYPE Statistics::var<TYPE>(std::vector<TYPE> const &); \
68 template TYPE Statistics::cov<TYPE>( \
69 TYPE const *, TYPE const *, int const &, int const &); \
70 template TYPE Statistics::cov<TYPE>( \
71 std::vector<TYPE> const &, std::vector<TYPE> const &); \
72 template TYPE Statistics::corr<TYPE>( \
73 TYPE const *, TYPE const *, int const &, int const &); \
74 template TYPE Statistics::corr<TYPE>( \
75 std::vector<TYPE> const &, std::vector<TYPE> const &);
#define STATISTICS_SPECIALIZE(TYPE)
T mean(const T *v, const int &dimension=3)
T cov(const T *v1, const T *v2, const int &dimension1=3, const int &dimension2=3)
T var(const T *v, const int &dimension=3)
T corr(const T *v1, const T *v2, const int &dimension1=3, const int &dimension2=3)