Oddities with the linfit function [message #91622] |
Thu, 06 August 2015 14:51  |
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   |
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  |
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
|
|
|