MATLAB: How to perform nonrepeating bootstrap resampling in MATLAB

Statistics and Machine Learning Toolbox

Resampling with bootstrap contains the possibility that repeated samples
might occur. I would like to sample a set to obtain a subset in which the elements of the subset do not contain repeated results.

Best Answer

A workaround is to generate a set of unique random indexes.
See the following code for an example:
N = 1000; % Size of your total set
Nsub = 5; % Size of the subset
nu = 0;
while(length(nu) < Nsub)
x = round(.5 + (N - eps(N+.5))*rand(1,10*Nsub));
[b1, nu, n1] = unique(x, 'first');
end
indexi = nu(1:Nsub) % Unique and random indexes for subset into
% the larger set.