function p=q3_2(x0,a) % Solution to question 3.2. since the multipliers c are not specified allow them as input. %All of x0,a,c,m are 2-dim vectors. This uses the second lcg to shuffle % results from the first. there are k=3 bins. m=[7 11]; n=20000; c=[0 0]; k=3; 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 p=period2(x,20);