encog-dotnet-core
encog-dotnet-core copied to clipboard
Performance optimization for NormalizedField.DeNormalize
Hi,
I've taken a look at method *DeNormalize of the *NormalizedField class. I think we can improve the performance of this method with the following code:
public double DeNormalize(double v)
{
return ((v - _normalizedLow)*(_actualHigh - _actualLow)
/(_normalizedHigh - _normalizedLow)) + _actualLow;
}
I've made some benchmark and it seems that with this equation, the result is 20% quicker. Can someone confirm my implementation.
Thanks
If this is confirmed, I suggest AnalystField.DeNormalize be modified for this performance gain, as well.
It's best to include your benchmark code with your results for an optimum control environment.
This test was run in F# interactive envrionment, resetting after modify-build:
open Encog
let rnl = [ for i in 1. .. 100000000. ->
let rnd = new System.Random() in
rnd.NextDouble()]
let nfl =
rnl
|> List.map (fun x -> let foo = new Encog.Util.Arrayutil.NormalizedField()
foo.DeNormalize (float x))
// Old Code
// Real: 00:00:45.398, CPU: 00:00:44.656, GC gen0: 3817, gen1: 754, gen2: 3
// New Code
// Real: 00:00:43.278, CPU: 00:00:42.781, GC gen0: 3816, gen1: 778, gen2: 2