フィルターのクリア

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 Center および File ExchangeGaussian Process Regression についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by