comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » More problems with Curvefit
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: More problems with Curvefit [message #35716 is a reply to message #35619] Mon, 30 June 2003 09:19 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Heather Williams wrote:
>
> Good afternoon, everyone. I'm having some problems using Curvefit (in
> IDL 5.4) to fit my data. I've reviewed the messages which have already
> been posted on this subject, and had a good look at the MPCURVEFIT
> substitute, but am no wiser.
>
> My code looks like this:
>
> PRO data_fit
>
> ;Define the vectors of tabulated:
>
> F18_x = FLTARR(12) & F18_x(0) = 9.055227833
> F18_x(1) = 9.908886278 & F18_x(2) = 11.86860889
> F18_x(3) = 13.281685 & F18_x(4) = 16.69834393
> F18_x(5) = 19.52864256 & F18_x(6) = 23.17273836
> F18_x(7) = 28.51793219 & F18_x(8) = 31.23624055
> F18_x(9) = 33.53401408 & F18_x(10) = 38.12262897
> F18_x(11) = 39.15701348
> F18_y = FLTARR(12) & F18_y(0) = 0.108598707
> F18_y(1) = 0.329883541 & F18_y(2) = 0.504690343
> F18_y(3) = 0.685805013 & F18_y(4) = 0.780161321
> F18_y(5) = 0.87284238 & F18_y(6) = 0.890067419
> F18_y(7) = 0.907523914 & F18_y(8) = 0.98011631
> F18_y(9) = 0.943832957 & F18_y(10) = 0.966238284
> F18_y(11) = 1
>
> X = FLTARR(12) & X(*) = F18_x(*) - F18_x(0)
> Y = FLTARR(12) & Y(*) = F18_y(*) - F18_x(0)
>
> ;Define a vector of weights:
> W = 1.0

Try doing

w = make_array(12, value = 1.0 )

or

w = replicate( 1.0, 12 )

to actually give you a vector for w. The IDL documentation is a wee bit misleading here as
the actual words say "For no weighting, set Weightsi = 1.0" where the "i" suffix is an
indicator that Weights is an array but it's not entirely clear (to me at least.)


This made your code work for me.....but I got the following:

% CURVEFIT: Failed to converge- CHISQ increasing without bound.
1.00000 1.00000
% Program caused arithmetic error: Floating overflow

Changing the line

yfit = CURVEFIT(X, Y, W, A, SIGMA_A, FUNCTION_NAME = 'fit_funct')

to use Craig's MPCURVEFIT

yfit = MPCURVEFIT(X, Y, W, A, SIGMA_A, FUNCTION_NAME = 'fit_funct')

gave me the following:

IDL> data_fit
% Compiled module: MPCURVEFIT.
% Compiled module: MPFIT.
Iter 1 CHI-SQUARE = 1215.4340 DOF = 10
P(0) = 1.00000
P(1) = 1.00000
Iter 2 CHI-SQUARE = 1212.4130 DOF = 10
P(0) = 0.887302
P(1) = 0.887302
Iter 3 CHI-SQUARE = 1208.7012 DOF = 10
P(0) = 0.776462
P(1) = 0.776462
Iter 4 CHI-SQUARE = 1203.9254 DOF = 10
P(0) = 0.665368
P(1) = 0.665368
Iter 5 CHI-SQUARE = 1189.1635 DOF = 10
P(0) = 0.448375
P(1) = 0.448375
Iter 6 CHI-SQUARE = 945.99725 DOF = 10
P(0) = 0.0271755
P(1) = 0.0271756
Iter 7 CHI-SQUARE = 440.82562 DOF = 10
P(0) = -0.0570307
P(1) = -0.0570309
-0.0570307 -0.0570309
% Program caused arithmetic error: Floating underflow
% Program caused arithmetic error: Floating overflow
% Program caused arithmetic error: Floating illegal operand

This output just *has* to be more meaningful wrt diagnostics than the curvefit output.

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Ph: (301)763-8000 x7748
Fax:(301)763-8545
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Format Code Question
Next Topic: IDL from crontab going defunct?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:37:55 PDT 2025

Total time taken to generate the page: 1.83737 seconds