Skip to content

Commit c5ef3b5

Browse files
Don't combine distribution if count == 0
1 parent f8d26b9 commit c5ef3b5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cbits/distrib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ void hs_distrib_add_n(struct distrib* distrib, StgDouble val, StgInt64 n) {
2929
// http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
3030
void hs_distrib_combine(struct distrib* b, struct distrib* a) {
3131
hs_lock(&b->lock);
32+
33+
if (!b->count) {
34+
return;
35+
}
36+
3237
const StgInt64 count = a->count + b->count;
3338
const StgDouble delta = b->mean - a->mean;
3439
const StgDouble mean = (a->count * a->mean + b->count * b->mean) / count;

0 commit comments

Comments
 (0)