I have tried to create a polynomial that fits some data using the
following code:
PolynomialFitter fitter = new PolynomialFitter(14, new
GaussNewtonOptimizer());
for (int i = 0; i < numValues; i++)
{
fitter.addObservedPoint(xValues[i], yValues[i]);
}
return new PolynomialFunction(fitter.fit());
I've also tried using a degree of 4. In both cases and using both a
GaussNewtonOptimizer and a LevenbergMarquardtOptimizer, I'm able to
get a straight line to be fitted correctly, but the following data
results with a constant value but very small multipliers for x, and
higher orders.
Is anyone able to let me know why this is happening and what I can do about
it?
Many thanks,
Mat.
The result I get is...
y = 110.281064 + 0.002316943x - 3.86E-09x^2 + 4.01E-15x^3 - 1.58E-21x^4
>From this data:
10000 100
20000 142
30000 174
40000 200
50000 224
60000 245
70000 265
80000 283
90000 300
100000 317
110000 332
120000 347
130000 361
140000 375
150000 388
160000 400
170000 413
180000 425
190000 436
200000 448
210000 459
220000 470
230000 480
240000 490
250000 500
260000 510
270000 520
280000 530
290000 539
300000 548
310000 557
320000 566
330000 575
340000 584
350000 592
360000 600
370000 609
380000 617
390000 625
400000 633
410000 641
420000 649
430000 656
440000 664
450000 671
460000 679
470000 686
480000 693
490000 700
500000 708
510000 715
520000 722
530000 729
540000 735
550000 742
560000 749
570000 755
580000 762
590000 769
600000 775
610000 782
620000 788
630000 794
640000 800
650000 807
660000 813
670000 819
680000 825
690000 831
700000 837
710000 843
720000 849
730000 855
740000 861
750000 867
760000 872
770000 878
780000 884
790000 889
800000 895
810000 900
820000 906
830000 912
840000 917
850000 922
860000 928
870000 933
880000 939
890000 944
900000 949
910000 954
920000 960
930000 965
940000 970
950000 975
960000 980
970000 985
980000 990
990000 995
1000000 1000