Avoiding loops in bootstrap
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Adam Danz
le 22 Oct 2020
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.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!