function B = permutewithreplacement(A)
B = NaN(size(A));
    for j = 1:size(A,2)
        for i = 1:size(A,1)
            while isnan(B(i,j))
            random = rand();
            B(i,j) = A(i,ceil(random*(size(A,2))));
            end
        end
    end
end