%input is M whose rows are abcdef where [ab;cd] is an linear transformation
% and [e;f] is a translation. 
%and p(j)  is a probability asignement for choosing the affine given by the
%j-the row of M

close
p=input('probability vector =  ');
M=input('M= ');
N=20000;
Q=randomNpvariable(N,p);
x=zeros(1,N+1);
y=zeros(1,N+1);
x(1)=rand;
y(1)=rand;
for j=1:N
	x(j+1)=M(Q(j),1)*x(j)+M(Q(j),2)*y(j)+M(Q(j),5);
	y(j+1)=M(Q(j),3)*x(j)+M(Q(j),4)*y(j)+M(Q(j),6);
end
plot(x,y,'.')
