iteration in bootstrap method
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
HI guys, i have a 1*39 cell array (M) and each cell contains different dimension numeric arrays(e.g. 74*3,68*3...), for each column i want to resample it with bootstrap. I guess boot function could only be applied on array numbers so i created M_1 to capture each column in the cell array. (i also tried to convert the whole cell table to array but did not succeed.) How can i put the code down below into a for loop and get the numeric arrays? Thank you so much if you could help.
M_1=M{1,1}(:,2);
[stats,bootsam]= bootstrp(100,@(x)[mean(x) std(x) moment(x,4) moment(x,3)],M_1);
0 Commenti
Risposta accettata
Adam Danz
il 23 Giu 2018
Follow this example. I loop through all elements of M and then all columns within each element of M.
% fake data
M = {rand(74,3); rand(68,3); rand(22,4)};
% get number of columns in each M
nCols = cellfun(@(x)size(x,2), M);
% initialize loop vars
stats = cell(length(M), max(nCols));
bootsam = stats;
% Loop through your cell array
for i = 1:length(M) %for each element of M
for j = 1:size(M{i},2) %for each column of M{i}
[s,b]= bootstrp(100,@(x)[mean(x) std(x) moment(x,4) moment(x,3)],M{i}(:,j));
stats{i,j} = s; %store values
bootsam{i,j} = b; %store values
end
end
% To get the results for M{1} column(2)
stats{1,2}
bootsam{1,2}
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!