Sunday, July 3, 2011

Simulate Discrete Random Variables

Discrete Simulation - simulate from a generic pdf

I should also see my simulation code from Cornell, that I personalized for this problem (if you weren't chosing numbers between 1 and K).

Built in Matlab
1. randi = random integer this is unifrom
2. randsample = weighted

CFX
1. gDiscrPdfRnd - I think this uses mex?
http://www.mathworks.com/matlabcentral/fileexchange/14469-performing-random-numbers-generator-from-a-generic-discrete-distribution
2. randp
http://www.mathworks.com/matlabcentral/fileexchange/8891

2 comments:

  1. Using randsample, sample the numbers 1,2,3 with a different weight

    R = randsample(3,48,true,[.6 .2 .2])

    ReplyDelete
  2. If you want different integers then 1,2 and 3
    >> randsample([1 3 7],10,'true',[1 1 1])

    ReplyDelete

Note: Only a member of this blog may post a comment.