function x=shuffledrng(x0,a,c,m,n)
% all of x0,a,c,m  are 2-dim vectors. This uses the second lcg to shuffle
% results from the first. there are k=4 bins.
% e.g. x=shuffledrng([3 3],[5 5],[0 0],[19 29],100)
k=4; n=n+k;
x1=lcg(x0(1),a(1),c(1),m(1),n);
bin=x1(1:k);
index=ceil((k/m(2))*lcg(x0(2),a(2),c(2),m(2),n));
x=[];
for i=1:(n-k)
    x=[x bin(index(i))];
    bin(index(i))=x1(i+k);
end

    
    
