comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: "duxiyu@gmail.com" <duxiyu@gmail.com> writes: > I have a set of 'x' and 'y', and want to use a special function 'f(x)' > to fit it. > The function 'f(x)' contains three parameters. > But I'm confused by the three different procudure 'curvefit', 'lmfit' > and 'svdfit'. > It seems that all of them can meet my request, but I don't know the > difference between them. SVDFIT is for fitting linear combinations of basis functions, probably not what you wanted. You could use LMFIT or CURVEFIT. You can also graduate straight to MPFIT and MPFITFUN which are both easier to use, and give you more options when you need them. Good luck! Craig See http://cow.physics.wisc.edu/~craigm/idl/idl.html (under Curve Fitting) -- ------------------------------------------------------------ -------------- Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response ------------------------------------------------------------ --------------
creator: Craig Markwardt
date: 2007-03-07T14:20:48-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: <duxiyu@gmail.com> wrote in message news:1173260085.952428.100150@q40g2000cwq.googlegroups.com.. . > I have a set of 'x' and 'y', and want to use a special function 'f(x)' > to fit it. > > The function 'f(x)' contains three parameters. > > But I'm confused by the three different procudure 'curvefit', 'lmfit' > and 'svdfit'. The difference is essentially between 1) linear least square error fits, and 2) non-linear least square error fit. In 1) you directly calculate the resulting fit. You start with the matrix equation Ax = b where x is the unknown. 'A 'is a matrix where your fitting function is evaluated at each point (and is usually not square). The LSF solution is: A^tAx = A^tb x = (A^tA)A^tb The svd routines solve this matrix equation. For 2) you make an error function error = data - nonlinear function(x) and you search around parameter space to try to find the minimum error. This may not converge, it probably depends on an initial guess, and can be very time consuming. This is what curvefit and the others do. If you can create a linear fit, then 1) is the way to go. If it is non-linear, google fpr mpfit, widely hailed as a superior non-linear fitting routine. (i'll google: http://cow.physics.wisc.edu/~craigm/idl/idl.html) Cheers, bob
creator: news.qwest.net
date: 2007-03-07T15:02:11-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: On Mar 7, 10:20 pm, Craig Markwardt <craigm...@REMOVEcow.physics.wisc.edu> wrote: > "dux...@gmail.com" <dux...@gmail.com> writes: >> I have a set of 'x' and 'y', and want to use a special function 'f(x)' >> to fit it. >> The function 'f(x)' contains three parameters. >> But I'm confused by the three different procudure 'curvefit', 'lmfit' >> and 'svdfit'. >> It seems that all of them can meet my request, but I don't know the >> difference between them. > > SVDFIT is for fitting linear combinations of basis functions, probably > not what you wanted. You could use LMFIT or CURVEFIT. > > You can also graduate straight to MPFIT and MPFITFUN which are both > easier to use, and give you more options when you need them. > > Good luck! > Craig > > Seehttp://cow.physics.wisc.edu/~craigm/idl/idl.html (under Curve Fitting) > -- > ------------------------------------------------------------ -------------- > Craig B. Markwardt, Ph.D. EMAIL: craigm...@REMOVEcow.physics.wisc.edu > Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response > ------------------------------------------------------------ -------------- Thank you very much! I have download the MPFIT package. Now I'm studying it. ^_^ But in your package there is not procedure named 'MPEVALEXPR' which is in the sentence 'yfit = MPEVALEXPR(expr, x, p) Expression named expr'. By the way, I wonder the difference between LMFIT and CURVEFIT very much. Are their function the same as each other? Best regards, Du Jian
date: 2007-03-08T01:08:29-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: On Mar 7, 11:02 pm, "R.G. Stockwell" <n...@email.please> wrote: > <dux...@gmail.com> wrote in message > > news:1173260085.952428.100150@q40g2000cwq.googlegroups.com.. . > >> I have a set of 'x' and 'y', and want to use a special function 'f(x)' >> to fit it. > >> The function 'f(x)' contains three parameters. > >> But I'm confused by the three different procudure 'curvefit', 'lmfit' >> and 'svdfit'. > > The difference is essentially between 1) linear least square error fits, > and 2) non-linear least square error fit. > > In 1) you directly calculate the resulting fit. > You start with the matrix equation > Ax = b > > where x is the unknown. 'A 'is a matrix where your > fitting function is evaluated at each point (and is usually > not square). > > The LSF solution is: > > A^tAx = A^tb > x = (A^tA)A^tb > > The svd routines solve this matrix equation. > > For 2) you make an error function > error = data - nonlinear function(x) > > and you search around parameter space to try to > find the minimum error. This may not converge, it probably > depends on an initial guess, and can be very time consuming. > This is what curvefit and the others do. > > If you can create a linear fit, then 1) is the way to go. > If it is non-linear, google fpr mpfit, widely hailed as a superior > non-linear fitting routine. > (i'll google: http://cow.physics.wisc.edu/~craigm/idl/idl.html) > > Cheers, > bob Thanks for your explaination. In your statement 1) means SVDFIT and 2) means LMFIT and CURVEFIT, doesn't it? When I want to create a linear fit, there are many choices like LINFIT, LADFIT and SVDFIT. But I'm confused which one I should select. Best regards, Du Jian
date: 2007-03-08T01:19:02-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: "duxiyu@gmail.com" <duxiyu@gmail.com> writes: > Thank you very much! > I have download the MPFIT package. > Now I'm studying it. ^_^ > But in your package there is not procedure named 'MPEVALEXPR' which is > in the sentence 'yfit = MPEVALEXPR(expr, x, p) Expression named expr'. It's hidden inside mpfitexpr.pro, and only needed if you want to evaluate a user expression for parameter values *other* than the best fit values. Given that most people would use MPFITEXPR() interactively from the command line, this is not a problem. (You can also use 'forward_function mpevalexpr' to make sure it is available in canned a script.) This is of course not an issue with MPFITFUN(), which I recommended. > By the way, I wonder the difference between LMFIT and CURVEFIT very > much. > Are their function the same as each other? CURVEFIT - poor man's non-linear least squares original to IDL, based on gradient expansion and not really robust. LMFIT - probably more robust non-linear least squares with Levenberg-Marquardt technique. It still has some fatal flaws, like evaluating the user function one point at a time. This routine was released after MPFIT. LINFIT - for fitting a straight line to XY data only. POLY_FIT - for fitting a polynomial to XY data. SVDFIT - for fitting a linear combination of any basis functions. LADFIT - for fitting a straight line, but *not* least squares (more robust against outliers) Good luck, Craig -- ------------------------------------------------------------ -------------- Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response ------------------------------------------------------------ --------------
creator: Craig Markwardt
date: 2007-03-08T02:07:36-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: On 07 Mar 2007 21:07:36 -0500, Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote: <snip> > CURVEFIT - poor man's non-linear least squares original to IDL, based > on gradient expansion and not really robust. <snip> I always thought CURVEFIT was using Levenberg-Marquardt. Check the use of lambda, which allows the alternation between gradient and expansion method (which is the Levenberg-Marquardt as far as I know).
creator: Wox
date: 2007-03-08T09:53:54-00:00

Re: What is the difference between 'curvefit', 'lmfit' and 'svdfit' procudure?
type: item
description: Wox wrote: > On 07 Mar 2007 21:07:36 -0500, Craig Markwardt > <craigmnet@REMOVEcow.physics.wisc.edu> wrote: > > <snip> >> CURVEFIT - poor man's non-linear least squares original to IDL, based >> on gradient expansion and not really robust. > <snip> > > I always thought CURVEFIT was using Levenberg-Marquardt. Check the use > of lambda, which allows the alternation between gradient and expansion > method (which is the Levenberg-Marquardt as far as I know). Regardless, CURVEFIT is nowhere near as robust as Craig's replacement for it. A while back I used CURVEFIT on some data I was trying to fit (infrared sea surface emissivity that depended on frequency, wind speed, and view angle) and, when I did get convergence, it took forever. Using MPFIT (not changing anything else related to the data I was fitting), I *always* got convergence and it ran orders of magnitude faster. Single data point anecdotal evidence I know, but there you go. cheers, paulv -- Paul van Delst Ride lots. CIMSS @ NOAA/NCEP/EMC Eddy Merckx
creator: Paul Van Delst[1]
date: 2007-03-08T15:53:23-00:00