jeffheaton / encog-java-core

http://www.heatonresearch.com/encog
Other
742 stars 268 forks source link

NormaliseArray/NormaliseField incorrect for negative number arrays #224

Closed philclaridge closed 6 years ago

philclaridge commented 8 years ago

I have been normalising arrays of negative numbers. The high value is incorrectly reported as 4.9E-324, not say -5 for an array of numbers in range say of -5 to -8.

Looking here https://github.com/encog/encog-java-core/blob/master/src/main/java/org/encog/util/arrayutil/NormalizedField.java line 109 appears incorrect it is:

this.actualHigh = Double.MIN_VALUE;

and I think it should be

this.actualHigh = -Double.MAX_VALUE;

This is because Double.MIN_VALUE is defined as the smallest positive number a double can be not the largest negative number. See this old stack overflow thread: http://stackoverflow.com/questions/3884793/why-is-double-min-value-in-not-negative

AFAIK this is only a Java issue, see http://stackoverflow.com/questions/16526467/difference-between-java-and-c-sharp-doubles

This issue was previously incorrectly posted in the .net encong issues.

Best, Phil

jeffheaton commented 6 years ago

Thank you very much for this information and the stack overflow discussion. I will put this in the next Encog release.