×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Rejection method

Rejection method

Rejection method

(OP)
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(n)

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,


RE: Rejection method

Are you aware of that your for-loop is useless? The loop variable i is never used. Could this be the problem?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources