mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added a stddev() for matrix objects.
This commit is contained in:
parent
daecb0ec85
commit
e2fdff8ca5
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user