I am trying to make some calculus in Java related to entropies and information gain and I use a formula that looks like this: info_gain = infogain - nr1 / nr2 * nr3.
nr1, nr2, nr3 and infogain are doubles.
The problem is that the result from nr1 / nr2 * nr3 is corect. But when I do the subtraction I get some ugly results.
For example nr1 / nr2 * nr3 is 0.574716 and the initial value of the infogain is 0.575306. When I do the substraction I get 0.000589. That's not correct or is not what is supposed to return (I did the calculus on paper).
I tried to use BigDecimal using MathContext.DECIMAL64 and for divide(nr, 10, RoundingMode.HALF_UP).
So, is there any posibility to get the result from above 0.001? (or something similar, but not 0.000589).
Uhh, 0.575306 - 0.574716 is in fact 0.00059.