Random Integers from a preconstructed non uniform distribution
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 4 de Dic. de 2012
It appears to me that you are changing the pmf according to what has already been generated ??
Michael
el 4 de Dic. de 2012
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Descriptive Statistics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!