function y=expo(s,lambda) 
// P(y=t)= lambda*(exp(-lambda t))
//
y=(-1/lambda)* log(1-rand(s,1));
//
//--------------------------------------
function y=geom(s,p) 
// P(y=0)= 0 P(y=i) = p*(1-p)^{i-1} P(inf)=0
//
y=zeros(s,1)
for i=1:s
	samples=1
	z=rand();
	while( z > p) ,z=rand(); samples=samples+1;end
	y(i)= samples;
end
//
//--------------------------------------
function y=binom(s,p,n) 
// P{y=k} = C_n^k p^k (1-p)^(n-k)
//
y=rand(s,n);
indy= find(y<p);
y=zeros(y);
y(indy)=1;
y=sum(y,'c');
//
//--------------------------------------
function y=pois(s,p) 
// P{y=n} = exp(-p)p^n/n!
// 
y=zeros(s,1)
for i=1:s
   count=0
   lprod=1
   while( lprod >= exp(-p)), lprod=lprod*rand();
      count=count+1;
   end
   y(i)=count-1;
end