function [bootsem, mu] = bootstrapmean( x, resample )
% computes standard error by bootstrapping the data
% x: vector with data
% resample: number of resamplings
% returns:
% bootsem: the standard error of the mean
% mu: the bootstrapped means as a vector
    mu = zeros( resample, 1 );
    nsamples = length(x);
    for i = 1:resample
        % resample:
        xr = x(randi(nsamples, nsamples, 1));
        % compute statistics on sample:
        mu(i) = mean(xr);
    end
    bootsem = std( mu );
end