quick calculation in one second
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, if there is a sequence x(i) (more than 1 million number points), how to optimize the algorithm and calculate the equation below in about one second? Thanks!

N = length(x);
J=[1 2 4 10 20 40 100 200 400 1000 2000 4000 10000 20000 40000 100000 200000 400000 1000000];
for h=1:1:19
q = J(h);
if (q<=N/3)
p(1:1:N-3*q+1)=0;
for j=1:1:(N-3*q+1)
p(j)=sum(x(j+2*q:1:j+3*q-1))-2*sum(x(j+q:1:j+2*q-1))+sum(x(j:1:j+q-1));
end
time(h)=q;
Stability(h) = sqrt(sum(p.*p)/(6*q*q*(N-3*q+1)));
end
end
0 件のコメント
回答 (1 件)
Walter Roberson
2016 年 3 月 14 日
This appears to be the same equation as your previous question http://www.mathworks.com/matlabcentral/answers/270756-quick-numerical-calculation-without-for-loop
Florian was able to suggest a method there that took about 11 seconds in a parallel environment. Are you running a parallel environment?
Do you have a reason to expect that your formula can be calculated in about 1 second on whatever machine you are using?
2 件のコメント
Walter Roberson
2016 年 3 月 14 日
You will not be able to evaluate that within 1 second by executing that formula in a straight-forward way. Each term is summed multiple times, with the overall number of summations on the order of magnitude of 6*m^2
参考
カテゴリ
Help Center および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!