We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d475105 commit 6ce1a31Copy full SHA for 6ce1a31
opencog/matrix/entropy.scm
@@ -235,13 +235,13 @@
235
; = sum_x h_left(x)
236
; = sum_y h_right(y)
237
; It throws an error if the two are not equal (to within guessed
238
- ; rounding errors.)
+ ; rounding errors.) Don't throw, if run on an empty dataset.
239
(define (compute-total-entropy)
240
(define lsum (left-sum
241
(lambda (x) (frqobj 'left-wild-entropy x))))
242
(define rsum (right-sum
243
(lambda (x) (frqobj 'right-wild-entropy x))))
244
- (if (< 1.0e-8 (/ (abs (- lsum rsum)) lsum))
+ (if (and (0 < lsum) (< 1.0e-8 (/ (abs (- lsum rsum)) lsum)))
245
(throw 'bad-summation 'compute-total-entropy
246
(format #f
247
"Left and right entropy sums fail to be equal: ~A ~A\n"
0 commit comments