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

Home » Public Forums » archive » Oddities with the linfit function
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
Oddities with the linfit function [message #91622] Thu, 06 August 2015 14:51 Go to next message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
I've got an array for X, and an array for y.

so I do this

plot, x,y, psym=1
result=linfit(x,y)
print, result

and instead of getting the usual 2 things that are the m and the b of the y=mx+b, I get three. The first two things I think are the m and b, and the third thing I though was the r^2. But if I multiply the x value by -1 so everything flips, then do linfit, I get the identical third value, but negative...

Not sure why I get three things, and I'm not sure how to get the real r^2 value.

Thanks for your help!
Re: Oddities with the linfit function [message #91624 is a reply to message #91622] Thu, 06 August 2015 15:04 Go to previous messageGo to next message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
I've also used the correlate function, and I get the same negative number as the 3rd value... But, then why would it be negative? It looks like it does follow the general data trend...


On Thursday, August 6, 2015 at 2:51:21 PM UTC-7, Wayana Dolan wrote:
> I've got an array for X, and an array for y.
>
> so I do this
>
> plot, x,y, psym=1
> result=linfit(x,y)
> print, result
>
> and instead of getting the usual 2 things that are the m and the b of the y=mx+b, I get three. The first two things I think are the m and b, and the third thing I though was the r^2. But if I multiply the x value by -1 so everything flips, then do linfit, I get the identical third value, but negative...
>
> Not sure why I get three things, and I'm not sure how to get the real r^2 value.
>
> Thanks for your help!
Re: Oddities with the linfit function [message #91625 is a reply to message #91622] Thu, 06 August 2015 15:08 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Thursday, August 6, 2015 at 11:51:21 PM UTC+2, Wayana Dolan wrote:
> I've got an array for X, and an array for y.
>
> so I do this
>
> plot, x,y, psym=1
> result=linfit(x,y)
> print, result
>
> and instead of getting the usual 2 things that are the m and the b of the y=mx+b, I get three. The first two things I think are the m and b, and the third thing I though was the r^2. But if I multiply the x value by -1 so everything flips, then do linfit, I get the identical third value, but negative...
>
> Not sure why I get three things, and I'm not sure how to get the real r^2 value.
>
> Thanks for your help!

Kind of impossible. Are you using the "right" linfit from IDL that is found in /lib/linfit.pro?
If you can debug, try to step in the function and see where it brings you.
Or maybe even easier, try:
print, routine_info('linfit', /source, /function)

See also http://www.exelisvis.de/docs/LINFIT.html

Cheers,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: cgScatter2D label
Next Topic: What's New in IDL 8.4

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

Current Time: Wed Oct 08 09:13:06 PDT 2025

Total time taken to generate the page: 0.00454 seconds