function z=lcgshuffle(x,y,m2,k) %input two long sequences of x nd y. shuffles the sequence x using the sequence y and k bins i=ceil(k*(y+.5)/m2); z=[]; m=[]; T=x(1:k); for j=1:(length(x)-4) z=[z T(i(j))]; T(i(j))=x(j+4); end %test period by looking for a repetition of the first 9 numbers. for j=10:(length(z)-8) m=[m sum(z(1:9)==z(j:(j+8)))]; end ['maximum length of repeated string (first 9 digits) ',num2str(max(m))]