X-Received: by 10.224.137.68 with SMTP id v4mr9808445qat.1.1377098483343;
        Wed, 21 Aug 2013 08:21:23 -0700 (PDT)
X-Received: by 10.49.28.97 with SMTP id a1mr337211qeh.0.1377098483326; Wed, 21
 Aug 2013 08:21:23 -0700 (PDT)
Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!feeder.erje.net!us.feeder.erje.net!news.ripco.com!news.glorb.com!fx3no3897153qab.0!news-out.google.com!he10ni2777qab.0!nntp.google.com!fx3no3897150qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.soft-sys.matlab
Date: Wed, 21 Aug 2013 08:21:23 -0700 (PDT)
In-Reply-To: <jjmeh4$bec$1@newscl01ah.mathworks.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.110.241.140;
 posting-account=BVvr6AoAAAA8rmqLeZ8_DWpo8Jk0SSCF
NNTP-Posting-Host: 129.110.241.140
References: <jjmald$lc$1@newscl01ah.mathworks.com> <jjmeh4$bec$1@newscl01ah.mathworks.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1aa30af-0430-4562-b63b-8c8636588633@googlegroups.com>
Subject: Re: xcorr and corr giving drastically different results
From: ihfw10@gmail.com
Injection-Date: Wed, 21 Aug 2013 15:21:23 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Lines: 48
Xref: news.mathworks.com comp.soft-sys.matlab:801236

Hi, Roger
A related quick question, can't Pearson correlation be used to measure similarity of two signals?
To my understanding, signal subtract mean value means delines the amplitudes of both signals.
Thank you!

-TigerHu
  


On Monday, March 12, 2012 10:22:12 PM UTC-5, Roger Stafford wrote:
> "James " <jfaghm@googlemail.com> wrote in message <jjmald$lc$1@newscl01ah.mathworks.com>...
> 
> > I am trying to computer to linear correlation between two timeseries.
> 
> > xcorr(X,Y,0,'coeff) = 0.9056; corr(X,Y) = -0.41
> 
> > I don't understand how we could have such different results?! When you look at the two time-series they are clearly anti-correlated. Can somebody explain why we get such results using xcorr?
> 
> > Figure: http://dl.dropbox.com/u/6156036/corr_plot.jpg
> 
> - - - - - - - - - -
> 
>   Those two functions are computing entirely different kinds of "correlation".  The Statistics Toolbox 'corr' function computes the Pearson correlation in which the mean value is subtracted before the product is taken, whereas the Signal Processing Toolbox 'xcorr' does not.  If I interpret your curves correctly their values are all well above zero, so that this difference in the functions' definitions has a large effect on the results.  For 'xcorr' you would expect a very positive figure and for 'corr', based on the appearance of the curves, a negative value.
> 
> 
> 
>   In calculating correlation you need to be aware of how it is defined by the various kinds of "correlation" functions.  It has a number of different definitions.  It is prudent to always experiment with each one using very short sequences to see if their computations agree with what you think they should be.
> 
> 
> 
> Roger Stafford