CORRELATE where is the problem? [message #65472] |
Sun, 08 March 2009 10:40  |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
Hi~ everyone. I have a simple question here. I have two arrays and I
calculated the correlation between them. The result is 0.49. But when
I use the equation to calculate the correlation. The result is 0.99.
And I can see from the plot that they are actually highly correlated.
Why is that? THX
openr,1,'data.txt'
data=fltarr(2,1227)
readf,1,data
temp=data(1,*)
oo=data(0,*)
;print,temp(0)
temp=reform(temp)
oo=reform(oo)
corr=CORRELATE(oo,temp)
print,corr
rr=LINFIT(temp,oo)
print,rr
plot,psym=2,temp,oo
|
|
|
Re: CORRELATE where is the problem? [message #65554 is a reply to message #65472] |
Mon, 09 March 2009 05:24  |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
On Mar 8, 1:40 pm, xiao <littledd...@gmail.com> wrote:
> Hi~ everyone. I have a simple question here. I have two arrays and I
> calculated the correlation between them. The result is 0.49. But when
> I use the equation to calculate the correlation. The result is 0.99.
> And I can see from the plot that they are actually highly correlated.
> Why is that? THX
>
> openr,1,'data.txt'
> data=fltarr(2,1227)
> readf,1,data
>
> temp=data(1,*)
> oo=data(0,*)
> ;print,temp(0)
>
> temp=reform(temp)
> oo=reform(oo)
>
> corr=CORRELATE(oo,temp)
> print,corr
> rr=LINFIT(temp,oo)
> print,rr
> plot,psym=2,temp,oo
Are you talking about the difference between corr and rr?
Correlate:
Return Value
If vectors of unequal lengths are specified, the longer vector is
truncated to the length of the shorter vector and a single correlation
coefficient is returned. If an m x n array is specified, the result
will be an m x m array of linear Pearson correlation coefficients,
with the element i,j corresponding to correlation of the ith and jth
columns of the input array.
Linfit:
Return Value
The result is a two-element vector containing the linear model
parameters [A, B].
Those two are less related than apples and oranges, more like apples
and peanuts.
Brian
------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
|
|
|
|