function [px py]=randiteralg(aw,bw,cw,dw,ew,fw,p,npoints)
  n=length(p);
  x=0;
  y=0;
  px=[];
  py=[];
  for j=1:npoints
    k=randint(p);
    x=aw(k)*x+bw(k)*y+ew(k);
    y=cw(k)*x+dw(k)*y+fw(k);
    px=[px; x];
    py=[py; y];
  endfor
endfunction