The 5.0 POLY_FIT has accuracy problems.
My app uses POLY_FIT extensively to solve a problem
which can be expressed as "choosing the very best of
many possible curve fittings".
I noticed the app was producing some wrong results, after
upgrading to IDL 5.0.
(I can presently run both 4.0 and 5.0)
I traced the problem to a key loop which performs
say 1000 curve fits and then chooses the X/Y set which had
the lowest error (sigma).
I inserted statements into the loop to print out the
X and Y values being fit, and then the resulting sigma values.
The X and Y values are all identical, and the sigma values
are mostly similar except on the important fit, the best
one, where 4.0's POLY_FIT gives a value like .37 but
5.0's gives ~ 1.9, a sixfold difference!
Unfortunately the app behaves poorly because any fit
over 1.0 error in the Y domain is considered bad, so the
program continues to search for a better one when it
has already found what is in fact the best one.
The fix for me was to copy the old POLY_FIT into
my app's directory and continue to use it.
I'd rather use the new one, if it's faster or somehow better,
but unless anyone can tell me where I went wrong, the better
accuracy of the old version is what I need.
------------------------------------------------------------
here's a nutshell showing the problem:
------------------------------------------------------------
IDL5> .run
- pks=[692,760,879,1030,1159,1177,1312,1436,1667,1790,1908]
- szs=[105,120,145,175,200,204,230,255,300,325,350]
-
- ; perform fits
-
- fit4=POLY_FIT4(pks,szs,3,yfit4,yband,sigma4,a) ; 4.0 version
- fit5=POLY_FIT (pks,szs,3,yfit5,yband,sigma5,a) ; 5.0 version
-
- ; print results
-
- print,'POLY_FIT4 gives sigma of:',sigma4
- print,'POLY_FIT5 gives sigma of:',sigma5
- print
- print,format='("POLY_FIT4 best fit:",20(F7.2))',yfit4
- print,format='("POLY_FIT5 best fit:",20(F7.2))',yfit5
- end
% Compiled module: $MAIN$.
% Compiled module: POLY_FIT4.
% Compiled module: POLY_FIT.
POLY_FIT4 gives sigma of: 0.37212247
POLY_FIT5 gives sigma of: 1.98881
POLY_FIT4 best fit: 105.28 119.82 144.59 175.05 200.47 203.99 230.27 254.39 300.05 325.13 349.95
POLY_FIT5 best fit: 105.65 120.27 145.19 175.86 201.50 205.05 231.58 255.97 302.20 327.63 352.81
|