jeffheaton / encog-java-core

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

MutatePerturb.performOperation calculation is not correct #148

Closed konical closed 10 years ago

konical commented 11 years ago

In org.encog.ml.genetic.mutate.MutatePerturb.performOperation():

As written this line will not work for small values. value += (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));

It should be changed to: value += value * (perturbAmount - (rnd.nextDouble() * perturbAmount * 2));

Examples: using perturbAmount = 0.2 and random perturbation = ( (perturbAmount - (rnd.nextDouble() * perturbAmount * 2)) ) = -0.1424

using encog calculation - value = 15, perturbation % = -0.842%, new value = 14.87 value = 0.001, perturbation % = -8771%, new value = -0.086713711

VALUE FOR SMALL NUMBER IS PERTURBED BY ~9000% !

using changed code: value = 15, perturbation % = -14.24%, new value = 12.86 value = 0.001, perturbation % =-14.24%, new value = 0.000857636

Value for small number is perturbed by the requested amount.

jeffheaton commented 11 years ago

Thanks good point. I will add this soon.

jeffheaton commented 10 years ago

Thank you good fix. I have this in the code now.