We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fb18a27 commit 90d8075Copy full SHA for 90d8075
src/functions/MutualInformation.cpp
@@ -91,9 +91,9 @@ double MutualInformation::calculate_MI (ElementSubset * X)
91
// H(Y) -= Pr(Y=y) * log (Pr(Y = y))
92
//
93
double Pr_Y_is_y = (double) freq_Y[i] / (double) m;
94
-
95
- H_Y -= Pr_Y_is_y * (log (Pr_Y_is_y) /
96
- log ((double) set->get_number_of_labels ()));
+ if (Pr_Y_is_y > 0)
+ H_Y -= Pr_Y_is_y * (log (Pr_Y_is_y) /
+ log ((double) set->get_number_of_labels ()));
97
}
98
99
delete [] freq_Y;
0 commit comments