Random Integers from a preconstructed non uniform distribution
Show older comments
Hi, I am looking to select random integers from a specified range that is not uniform. randi([1,interval]) does the job but this is a uniform distribution whereas I wish to change the probability mass function of the distribution on each iteration, the pmf is calculated with accumarray. I apologise if this is unclear but have posted the exact code below for clarity.
x=[1,2];
for j=1:T
if p/(p+j)>rand
x=[x,x(end)+1];
else
pmf = accumarray(x(2:length(x))',1); pmf = pmf./sum(pmf);
x=[x,x(randi([2,x(end)]))];
Many thanks
2 Comments
Walter Roberson
on 4 Dec 2012
It appears to me that you are changing the pmf according to what has already been generated ??
Michael
on 4 Dec 2012
Accepted Answer
More Answers (0)
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!