Efficient evaluation of Auto Regressive Covariance matrix

조회 수: 1 (최근 30일)
Sebastiano Piccolroaz
Sebastiano Piccolroaz 2020년 7월 9일
편집: Shubham Rawat 2020년 8월 25일
I need to improve the calculation of the following Covariance matrix (C), where p is the order of an autoregressive model and x(istart:istop) is the time series for which I would like to have C:
for i=0:p
for j=0:i
sum_=0;
for t=p+istart:istop
sum_ = sum_ + x(t-i)*x(t-j);
end
C(i+1,j+1)=sum_;
end
end

답변 (1개)

Shubham Rawat
Shubham Rawat 2020년 8월 24일
편집: Shubham Rawat 2020년 8월 25일
Hi Sebastiano,
You can do the following things to evaluate efficiently,
  • You can pre-initialize the Covariance(C) matrix by zeros or ones.
C = zeros(p+1,p+1);
  • You can Vectorize the code for specific tasks.
t = p+istart:istop;
cumulative_sum = cumsum(x(t-i).*x(t-j));
sum_ = cumulative_sum(last_element);
  • You can also parallelize the for loop by using parfor.
parfor t = p+istart:istop

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by