Commit 32602a1e authored by Julius Nehring-Wirxel's avatar Julius Nehring-Wirxel
Browse files

Added covariance.

parent 4555a2d5
......@@ -3,6 +3,7 @@
#include <typed-geometry/feature/vector.hh>
#include <typed-geometry/functions/matrix/adjugate.hh>
#include <typed-geometry/functions/matrix/covariance.hh>
#include <typed-geometry/functions/matrix/determinant.hh>
#include <typed-geometry/functions/matrix/diag.hh>
#include <typed-geometry/functions/matrix/eigenvalues.hh>
......
#pragma once
#include <typed-geometry/functions/basic/statistics.hh>
#include <typed-geometry/functions/matrix/outer_product.hh>
#include <typed-geometry/types/mat.hh>
namespace tg
{
template <class PosRangeT, class Transform = identity_fun>
auto covariance_matrix(PosRangeT&& r, Transform&& t = {}) -> decltype(self_outer_product(t(*tg::begin(r)) - t(*tg::begin(r))))
{
using MatT = decltype(self_outer_product(t(*tg::begin(r)) - t(*tg::begin(r))));
auto const avg = average(r, t);
MatT cov;
for (auto const& e : r)
cov += self_outer_product(t(e) - avg);
return cov;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment