Hibru
Bioengineer
- Nov 17, 2004
- 3
I wanted to have a exponential distribution from uniform distribution between 0 and 1.while I implement some methods in matlab I failed to solve the problem of rejecting points out of range.As a result I get fewer points between 0 and 1 in exponential distribution than uniform distribution.
I used the following program.
function [x,y,vx,vy]=exponential
rand('state',sum(100*clock))
%exponential distribution from uniform distribution
u =rand(1,n);
v= rand(1,n);
for i=1:n
x = -2*log(u);
y = -2*log(v);
end
[vx,vy]=voronoi(x,y);
plot(x,y,'b*',vx,vy,'r')
axis([0 1 0 1])
can any body help me?
Regards,
I used the following program.
function [x,y,vx,vy]=exponential
rand('state',sum(100*clock))
%exponential distribution from uniform distribution
u =rand(1,n);
v= rand(1,n);
for i=1:n
x = -2*log(u);
y = -2*log(v);
end
[vx,vy]=voronoi(x,y);
plot(x,y,'b*',vx,vy,'r')
axis([0 1 0 1])
can any body help me?
Regards,