mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Fixed the running_stats object so that the variance can never be negative.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402366
This commit is contained in:
parent
14ff48d30c
commit
3946767f6e
@ -121,8 +121,14 @@ namespace dlib
|
||||
<< "\n\tthis: " << this
|
||||
);
|
||||
|
||||
const T temp = n/(n-1);
|
||||
return temp*(sum_sqr - sum*sum);
|
||||
T temp = n/(n-1);
|
||||
temp = temp*(sum_sqr - sum*sum);
|
||||
// make sure the variance is never negative. This might
|
||||
// happen due to numerical errors.
|
||||
if (temp >= 0)
|
||||
return temp;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
T scale (
|
||||
|
Loading…
Reference in New Issue
Block a user