iteration in bootstrap method
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Adam Danz
le 23 Juin 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}
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!