Avoiding loops in bootstrap

1 回表示 (過去 30 日間)
Marco Lago
Marco Lago 2020 年 10 月 22 日
回答済み: Adam Danz 2020 年 10 月 22 日
I've nested loops to bootstrap a statistical test results. The code works but it's very slow. Is there a way to improve the below a structure and speed up the code:
for jj = 1:nreplications
Y_artificial %Simulate artificial data;
% Nested loop
for
%Perform test on recursive sub-samples of Y_artificial
end
end

回答 (1 件)

Adam Danz
Adam Danz 2020 年 10 月 22 日
Bootstrapping is an iterative process. Even if you use a method that doesn't require you to write a loop, the functions you're using will very likely use loops.
Loops likely aren't the bottleneck in your code. Something else it. You could use Matlab's profiler to time your code and produce a summary of time consumption.
Also note Matlab's bootstrapping functions
but depending on what you're bootstrapping, it may be easier to built it yourself.

カテゴリ

Help Center および File ExchangeResampling Techniques についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by