I'm using the Apache Commons Math package and I've got the following Sine Wave...
0.90, 0.85, 0.80, 0.83, 0.89
0.90, 0.85, 0.80, 0.83, 0.89
0.90, 0.85, 0.80, 0.83, 0.89
0.90, 0.85, 0.80, 0.83, 0.89
from the above data you can see that the wave has the following attributes...
- Amplitude =
.05 - Phase =
0 - Frequency =
5
However, when I add my sine wave to a HarmonicFitter like so...
HarmonicFitter fitter = new HarmonicFitter(new LevenbergMarquardtOptimizer());
fitter.addObservedPoint(0, 0.90);
fitter.addObservedPoint(1, 0.85);
fitter.addObservedPoint(2, 0.80);
fitter.addObservedPoint(3, 0.83);
fitter.addObservedPoint(4, 0.89);
fitter.addObservedPoint(5, 0.90);
fitter.addObservedPoint(6, 0.85);
fitter.addObservedPoint(7, 0.80);
fitter.addObservedPoint(8, 0.83);
fitter.addObservedPoint(9, 0.89);
fitter.addObservedPoint(10, 0.90);
fitter.addObservedPoint(11, 0.85);
fitter.addObservedPoint(12, 0.80);
fitter.addObservedPoint(13, 0.83);
fitter.addObservedPoint(14, 0.89);
fitter.addObservedPoint(15, 0.90);
fitter.addObservedPoint(16, 0.85);
fitter.addObservedPoint(17, 0.80);
fitter.addObservedPoint(18, 0.83);
fitter.addObservedPoint(19, 0.89);
double[] vals = fitter.fit();
return vals;
The values returned are more like...
Amplitude: 5.19813329138371
Frequency: 4.69209750375546E-5
Phase: 1.405312649084833
Why has the curve fitting resulted in such drastically different attributes for a sinewave with 4 identical frequencies?
But you can't distinguish the package's best fit function until you zoom way out to a window of
This also means that the package's best fit function is wildly unstable. A small change in your points will cause a large change in the output.