13 template<
typename UblasMatrix>
14 UblasMatrix
Cov(
const UblasMatrix &observations)
16 const size_t nobservations = observations.size1();
17 const size_t nsamples = observations.size2();
18 UblasMatrix result(nobservations, nobservations);
20 for (
size_t i = 0; i < nobservations; ++i)
22 for (
size_t j = 0; j <= i; ++j)
25 for (
size_t k = 0; k < nsamples; ++k)
27 result(i, j) += observations(i, k) * observations(j, k);
29 result(j, i) = result(i, j);
32 result /= (nsamples - 1);
UblasMatrix Cov(const UblasMatrix &observations)
Calculate the NxN covariance matrix for a NxM matrix of observations with 0 mean. ...