Skip to content

Commit

Permalink
Minor bugfix for empty datasets.
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Mar 7, 2023
1 parent d475105 commit 6ce1a31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opencog/matrix/entropy.scm
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@
; = sum_x h_left(x)
; = sum_y h_right(y)
; It throws an error if the two are not equal (to within guessed
; rounding errors.)
; rounding errors.) Don't throw, if run on an empty dataset.
(define (compute-total-entropy)
(define lsum (left-sum
(lambda (x) (frqobj 'left-wild-entropy x))))
(define rsum (right-sum
(lambda (x) (frqobj 'right-wild-entropy x))))
(if (< 1.0e-8 (/ (abs (- lsum rsum)) lsum))
(if (and (0 < lsum) (< 1.0e-8 (/ (abs (- lsum rsum)) lsum)))
(throw 'bad-summation 'compute-total-entropy
(format #f
"Left and right entropy sums fail to be equal: ~A ~A\n"
Expand Down

0 comments on commit 6ce1a31

Please sign in to comment.