Commit e2fdff8c authored by Davis King's avatar Davis King

Added a stddev() for matrix objects.

parent daecb0ec
......@@ -1767,6 +1767,18 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template <
typename EXP
>
const typename matrix_exp<EXP>::type stddev (
const matrix_exp<EXP>& m
)
{
return std::sqrt(variance(m));
}
// ----------------------------------------------------------------------------------------
// this is a workaround for a bug in visual studio 7.1
......
......@@ -1541,6 +1541,16 @@ namespace dlib
(i.e. 1.0/(m.nr()*m.nc() - 1)*(sum of all pow(m(i,j) - mean(m),2)))
!*/
// ----------------------------------------------------------------------------------------
const matrix_exp::type stddev (
const matrix_exp& m
);
/*!
ensures
- returns std::sqrt(variance(m))
!*/
// ----------------------------------------------------------------------------------------
const matrix covariance (
......
......@@ -299,6 +299,7 @@ namespace
}
DLIB_TEST(std::abs(variance(vector_to_matrix(a)) - rs1.variance()) < 1e-13);
DLIB_TEST(std::abs(stddev(vector_to_matrix(a)) - rs1.stddev()) < 1e-13);
DLIB_TEST(std::abs(mean(vector_to_matrix(a)) - rs1.mean()) < 1e-13);
for (int i = 10; i < 20; ++i)
......
Markdown is supported
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