Created
March 17, 2010 12:51
-
-
Save mutolisp/335189 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% mybootstrap function | |
% psilotum 2010/03/13 | |
% for GNU Octave | |
%% obj is the object, n is the final number | |
% and i is the bootstrapping repeat time | |
function[bootstrp] = mybootstrap(obj,n,i) | |
if columns(obj)==1 | |
% create i by n random numbers | |
rseed=ceil(n*rand(n,i)); | |
bootstrp=obj(rseed); | |
else | |
% Original method to create a n by i*2 matrix (obsoleted) | |
% bootstrp=[]; | |
% for k=1:i | |
% rseed=ceil(n*rand(1,n)); | |
% bootstrp=[bootstrp, obj(rseed,:)]; | |
% end | |
%% Grouped bootstrapping | |
% This will create a grouped multidimensional matrix | |
bootstrp=[]; | |
for j=1:i | |
rseed=ceil(n*rand(1,n)) ; | |
for k=1:columns(obj) | |
% Create a kth column boostrapped matrix | |
objbst=obj(rseed,k); | |
% Append all of the columns into a single | |
% multidimensional matrix | |
objbst_append(:,:,k)=objbst; | |
end | |
bootstrp=[bootstrp, objbst_append]; | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment