(c)Eamonn Keogh and Abdullah Mueen

function d = random_shuffle(d)

for k=1:30000
    i = ceil(rand()*size(d,1));
    j = ceil(rand()*size(d,1));
    if i ~= j && i < size(d,1) && j < size(d,1)
        x = d(i,:);
        d(i,:) = d(j,:);
        d(j,:) = x;
    end

end