## Compute median on subset

## default parameters
if !exist("nbruns")
  nbruns = 50;
endif
if !exist("boostsize")
  boostsize = 500;
endif

## check data size
if !exist("data")
  error ("can't work without data");
endif
[sampsize, nbvars] = size(data)
if sampsize < boostsize*10
  error ("not enough data");
endif

## initialize output
output = zeros(nbruns, nbvars);

## for earch run
for i=1:nbruns,
  run = randperm(sampsize)(1:boostsize);
  
  ## compute median
  output(i, :) = median(data(run, :));
  
endfor
