[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: running Person's correlation
From: |
Francesco Potortì |
Subject: |
Re: running Person's correlation |
Date: |
Mon, 02 Sep 2013 12:46:48 +0200 |
>> I have a signal (long) and a template (short, fixed). I have to compute
>> the Pearson's correlation of the short signal with a sliding window of
>> the long signal. This is a convolution where each sample is divided by
>> the (fixed) standard deviation of the short signal and the running
>> standard deviation of the long signal.
>>
>> The only loopless way I can think of is to compute a running sum, a
>> running sum of squares, and use them to compute a running standard
>> deviation to be multiplied with the convolution. Any more
>> straightforward methods?
>filter() is the function you need to vectorize your code. However, the
>big question is whether you need a causal algorithms (i.e. only samples
>from the past can be used), or whether you can use a symetric sliding
>window.
It should be causal, because after testing it has to be implemented on a
real-time system.
However, I do not mind about delays, so this should not be an issue.
> It will make a big difference how to estimate the running mean
>and standard deviation. Below, there is an outline of the code you are
>looking for, the code snippets are not tested
Thank you for the code. However, I do not want a long-term standard
deviation estimate. What I want is a running Pearson's correlation, so
the standard deviation has to be a running one, that is, computed over
the correlation window.
What I am looking for is not linear with respect to its input, so using
filter() is not enough. What I am doing now is to compute the
convolution (this can be done with filter) and then divide by a
running standard deviation computed using sum and sumsq.
--
Francesco Potortì (ricercatore) Voice: +39.050.621.3058
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it