Skip to content

Commit f7a7037

Browse files
committed
statistics: handle stddev of one element
1 parent 358cb01 commit f7a7037

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sampling/benchmark.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ struct statistics {
5050
double avg() {
5151
return mean;
5252
}
53-
double stddev() {
54-
// assert(count > 1);
55-
return sqrt(nvar / (count - 1));
53+
double stddev(size_t ddof = 1) {
54+
if (count <= 1) return 0.0;
55+
// ddof = delta degrees of freedom
56+
// Set to 0 if you have the entire distribution
57+
// Set to 1 if you have a sample (to correct for bias)
58+
return sqrt(nvar / (count - ddof));
5659
}
5760
};
5861

0 commit comments

Comments
 (0)