jeffheaton / encog-dotnet-core

http://www.heatonresearch.com/encog
Other
430 stars 150 forks source link

NormaliseArray/NormaliseField incorrect for negative number arrays #98

Closed philclaridge closed 8 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

Best, Phil

jeroldhaas commented 8 years ago

@philclaridge is there a way you can fit a small repro in a gist?

philclaridge commented 8 years ago

I need to check first if this is an issue with C#. I believe this is only a Java issue ... see http://stackoverflow.com/questions/16526467/difference-between-java-and-c-sharp-doubles

philclaridge commented 8 years ago

Only a Java issue, will post in Java encog group