Commit 3946767f authored by Davis King's avatar Davis King

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
parent 14ff48d3
......@@ -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 (
......
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