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

Home » Public Forums » archive » CURVFIT with XY error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
CURVFIT with XY error [message #88447] Sun, 27 April 2014 14:31 Go to next message
amin farhang is currently offline  amin farhang
Messages: 39
Registered: November 2010
Member
Hi,

Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?

data sample:

X = [0.8, 2.2, 3.3, 4.8, 5.8]
Y = [2.02, 2.78, 3.58, 5.05, 6.35]
Xerr = 0.03*X
Yerr = 0.05*Y


Best regards,
Re: CURVFIT with XY error [message #88466 is a reply to message #88447] Tue, 29 April 2014 21:01 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Sunday, April 27, 2014 5:31:55 PM UTC-4, Amin Farhang wrote:
>
> Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?

Not in IDL for the general case. Numerical recipes does give an algorithm for errors in both variables if the model function is purely linear.

Craig
Re: CURVFIT with XY error [message #90188 is a reply to message #88447] Mon, 09 February 2015 10:05 Go to previous messageGo to next message
brubaker.phil is currently offline  brubaker.phil
Messages: 5
Registered: February 2015
Junior Member
On Sunday, April 27, 2014 at 2:31:55 PM UTC-7, Amin Farhang wrote:
> Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?
>
CurvFit supplies the fortranCalculus code it used to create CurvFit. You could modify this code how ever you need and then re-compile it using the FC-Compiler (http://fortranCalculus.info/apps/fc-compiler.html) ... it's free!
Re: CURVFIT with XY error [message #90189 is a reply to message #90188] Mon, 09 February 2015 10:10 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Monday, February 9, 2015 at 1:05:53 PM UTC-5, brubak...@gmail.com wrote:
> On Sunday, April 27, 2014 at 2:31:55 PM UTC-7, Amin Farhang wrote:
>> Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?
>>
> CurvFit supplies the fortranCalculus code it used to create CurvFit. You could modify this code how ever you need and then re-compile it using the FC-Compiler (http://fortranCalculus.info/apps/fc-compiler.html) ... it's free!

I think you've got the wrong CURVFIT, fellow.
Re: CURVFIT with XY error [message #90190 is a reply to message #88466] Mon, 09 February 2015 11:42 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
You might also look at the code MPFITEXY by Michael Willliams to apply MPFIT to linear models with errors in both coordinates.

http://user.astro.columbia.edu/~williams/mpfitexy/

But again this does apply to general nonlinear models. --Wayne

On Wednesday, April 30, 2014 at 12:01:28 AM UTC-4, Craig Markwardt wrote:
> On Sunday, April 27, 2014 5:31:55 PM UTC-4, Amin Farhang wrote:
>>
>> Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?
>
> Not in IDL for the general case. Numerical recipes does give an algorithm for errors in both variables if the model function is purely linear.
>
> Craig
Re: CURVFIT with XY error [message #90196 is a reply to message #90189] Tue, 10 February 2015 08:42 Go to previous messageGo to next message
brubaker.phil is currently offline  brubaker.phil
Messages: 5
Registered: February 2015
Junior Member
On Monday, February 9, 2015 at 10:10:48 AM UTC-8, Craig Markwardt wrote:

> I think you've got the wrong CURVFIT, fellow.

If so, I have CurvFit name as my trademark and no one else can use it.


Phil
Re: CURVFIT with XY error [message #90197 is a reply to message #90196] Tue, 10 February 2015 09:16 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Tuesday, February 10, 2015 at 11:42:14 AM UTC-5, brubak...@gmail.com wrote:
> On Monday, February 9, 2015 at 10:10:48 AM UTC-8, Craig Markwardt wrote:
>
>> I think you've got the wrong CURVFIT, fellow.
>
> If so, I have CurvFit name as my trademark and no one else can use it.
>
>
> Phil

A search of the USPTO Trademark Electronic Search System (TESS) turns up
just one trademark for CurvFit, that being for the Curvfit Razor Company.
The registration was filed in 1925, and has since expired.

Anyhow, the IDL routine is called CURVEFIT, with an E.
Re: CURVFIT with XY error [message #90199 is a reply to message #88447] Tue, 10 February 2015 10:33 Go to previous messageGo to next message
Russell[1] is currently offline  Russell[1]
Messages: 101
Registered: August 2011
Senior Member
I am only aware of this working for fitting a linear function:

y= m*x + b

But for that, you can use Brandon Kelly's fitexy.pro in astrolib:

http://idlastro.gsfc.nasa.gov/contents.html


http://idlastro.gsfc.nasa.gov/ftp/pro/math/fitexy.pro


Are you sure your function is nonlinear? I mean, is there any transformation you can apply to force it to be linear?

-Russell


On Sunday, April 27, 2014 at 5:31:55 PM UTC-4, Amin Farhang wrote:
> Hi,
>
> Is there any replacing routine for CURVFIT which was able to do a non-linear least squares fit to a user-supplied function by considering both X and Y error?
>
> data sample:
>
> X = [0.8, 2.2, 3.3, 4.8, 5.8]
> Y = [2.02, 2.78, 3.58, 5.05, 6.35]
> Xerr = 0.03*X
> Yerr = 0.05*Y
>
>
> Best regards,
Re: CURVFIT with XY error [message #90200 is a reply to message #90199] Tue, 10 February 2015 11:11 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, February 10, 2015 at 1:33:18 PM UTC-5, rrya...@gmail.com wrote:
> Are you sure your function is nonlinear? I mean, is there any transformation you can apply to force it to be linear?

Things can get a little tricky when the function is non-monotonic. Linear, exponential and power law models are all monotonic, and will work fine with errors in X and Y, but you can also transform those into linear space and use MPFITEXY / FITEXY. This works because the function is single-valued whether it is expressed as y = f(x) or x = g(y).

Once your function has any bumps or wiggles, it's no longer a single-valued function in both x and y. Error bars in the x direction make it ambiguous whether a data point is attached to the left side of a wiggle, or the right side of it. This depends on how sharp the wiggles are, and how small the error bars are.

All this doesn't mean that fitting won't work, but it might mean that the fit converges to a local minimum which is not the global best fit. I.e., extra care is needed.

Craig

P.S. To Phil Brubaker, as already pointed out, the IDL subroutine is called CURVEFIT, and it has existed within IDL since 1982. Good luck with your trademark action.
Re: CURVFIT with XY error [message #90248 is a reply to message #90200] Fri, 13 February 2015 11:30 Go to previous message
brubaker.phil is currently offline  brubaker.phil
Messages: 5
Registered: February 2015
Junior Member
On Tuesday, February 10, 2015 at 11:11:08 AM UTC-8, Craig Markwardt wrote:
> P.S. To Phil Brubaker, as already pointed out, the IDL subroutine is called CURVEFIT, and it has existed within IDL since 1982. Good luck with your trademark action.

My CurvFit (TM) has been in use since the early 1990s. It handles non-linear curves if that is of interest to you; http://fortranCalculus.info/apps/curvfit.html

Phil
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL array subscripting issue
Next Topic: mpfitfun and complex data

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

Current Time: Wed Oct 08 09:19:20 PDT 2025

Total time taken to generate the page: 0.00454 seconds