%clear ary,l=10000;for i=1:l,i, ary(i)=odev4(1,100);end;hist(ary,100)
%clear ary,l=10000;for i=1:l,i, ary(i)=odev4(2,100);end;hist(ary,100)
function out=odev4(sec,param)
if sec==1
    out=log(1-rand)/(-1*param);
end
if sec==2
    tmp=(floor(100*rand)+1)/100;
    sum=0;
    for i=0:100*param
        sum=sum+param^i/factorial(i);
        if exp(-param)*sum>tmp break
        end
    end
    out=i-1;
end

        