How to compute sliding or running window correlation coefficient?
조회 수: 80 (최근 30일)
이전 댓글 표시
Dear colleagues,
I want to compute the sliding or running window correlation coefficient. I have read related papers, the formula is as following:
t=n,n+1,n+2,n+3,......。 n means the length of silding or running window.
Could you translate this formula into Matlad codes? Any help is very much appreciated! Many many thanks!
댓글 수: 2
Roger Stafford
2015년 4월 3일
See my reply at your previous thread:
http://www.mathworks.com/matlabcentral/answers/195874
답변 (2개)
Victor
2016년 9월 6일
편집: Victor
2016년 9월 6일
For a fast computation you can implement moving sums of X and X^2 for both signals, then obtain moving averages and variances as
M = sum(X)/windowLen;
V = ( sum(X^2) - sum(X)^2 )/windowLen;
Then find sum
V12 = sum( (X1-M1)*(X2-M2) );
And then sliding correlation itself:
C = V12 / sqrt(V1*V2);
It can be done efficiently within one for loop by adding one new value and substacting the old one.
*The same way we can find statistical moments, by adding moving sums of higher powers - X^3, X^4 etc.
**Additionally, you can add any span value for integer decimation.
댓글 수: 0
David J. Mack
2017년 12월 21일
If someone encounters this problem, I have written a function in analogy to the MOVSUM function, which compute the moving Pearson correlation:
Greetings, David
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!