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

Home » Public Forums » archive » CORRELATE where is the problem?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: CORRELATE where is the problem? [message #65554 is a reply to message #65472] Mon, 09 March 2009 05:24 Go to previous messageGo to previous message
Brian Larsen is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Function Makes Unexpected Appearance
Next Topic: Use of ++ operator to count frequency of an entry (Was: Majority Voting)

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

Current Time: Sat Oct 11 14:27:57 PDT 2025

Total time taken to generate the page: 0.29771 seconds