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
Subscribe to:
Post Comments (Atom)
Using randsample, sample the numbers 1,2,3 with a different weight
ReplyDeleteR = randsample(3,48,true,[.6 .2 .2])
If you want different integers then 1,2 and 3
ReplyDelete>> randsample([1 3 7],10,'true',[1 1 1])