next up previous
Next: Simulation of a Weibull Up: Random laws simulation Previous: Simulation of a Poisson

Simulation of an exponential random variable

Function code:

 
function [y]=Exp(m,n,lambda)
// lambda exp(-lambda x) x>=0 
// ---------------------------
y=(-1/lambda)* log(rand(m,n,'uniform'));

Simulation code:

n=1000;
lambda=3;
y=Exp(1,n,lambda);
histplot([0:0.1:10],y,[1,1],'051',' ',[0,0,5,3]);
deff('[y]=f(x)','y=lambda*exp(-lambda*x);');
x=[0:0.1:10]';plot2d(x,f(x),1,"000");
titre= 'macro histplot : Histogram plot';
xtitle(titre,'Classes','N(C)/Nmax');

\fbox{\epsfig{file=foo0_86.eps,width=3.75in}}


Scilab group