BOOTSTRP Bootstrap statistics. BOOTSTAT = BOOTSTRP(NBOOT,BOOTFUN,D1,...) draws NBOOT bootstrap data samples, computes statistics on each sample using the function BOOTFUN, and returns the results in the matrix BOOTSTATS. NBOOT must be a positive integer. BOOTFUN is a function handle specified with @. Each row of BOOTSTAT contains the results of applying BOOTFUN to one bootstrap sample. If BOOTFUN returns a matrix or array, then this output is converted to a row vector for storage in BOOTSTAT. The third and later input arguments (D1,...) are data (scalars, column vectors, or matrices) that are used to create inputs to BOOTFUN. BOOTSTRP creates each bootstrap sample by sampling with replacement from the rows of the non-scalar data arguments (these must have the same number of rows). Scalar data are passed to BOOTFUN unchanged. [BOOTSTAT,BOOTSAM] = BOOTSTRP(...) returns BOOTSAM, a matrix of indices into the rows of the extra arguments. To get the output samples BOOTSAM without applying a function, set BOOTFUN to empty ([]). Examples: Compute a sample of 100 bootstrapped means of random samples taken from the vector Y, and plot an estimate of the density of these bootstrapped means: y = exprnd(5,100,1); m = bootstrp(100, @mean, y); [fi,xi] = ksdensity(m); plot(xi,fi); Compute a sample of 100 bootstrapped means and standard deviations of random samples taken from the vector Y, and plot the bootstrap estimate pairs: y = exprnd(5,100,1); stats = bootstrp(100, @(x) [mean(x) std(x)], y); plot(stats(:,1),stats(:,2),'o') Estimate the standard errors for a coefficient vector in a linear regression by bootstrapping residuals: load hald ingredients heat x = [ones(size(heat)), ingredients]; y = heat; b = regress(y,x); yfit = x*b; resid = y - yfit; se = std(bootstrp(1000, @(bootr) regress(yfit+bootr,x), resid)); Bootstrap a correlation coefficient standard error: load lawdata gpa lsat se = std(bootstrp(1000,@corr,gpa,lsat)); See also random, randsample, hist, ksdensity. Reference page in Help browser doc bootstrp