Implementing a Simple Algorithm with Loops
5 次查看(过去 30 天)
显示 更早的评论
Hi
I want to implement the following algorithm:
I have a value a = 1000. I want to draw a random number from the geometric distribution with probability of success 0.3 on the support [1,..,1000] (that means that the random number should lie between one and one thousand). When this is done, say I have the random number 5, I subtract this number from a, and would store then 995 and 5. Then I would randomly chose either 995 or 5: in case 995 is chosen I draw again a geometric random number with the same probability of success as before but with support [1,..,995] (In case 5 is chosen, I draw a random number from the geometric distribution on the support [1,...,5] etc.). Say now the random variable is 10. Then I would subtract 995 - 10 and would be left with the three pieces: 5, 985 and 10. Then I would again chose between 985 and 10 and repeat this procedure until I get stuck with a piece with length 1.
How can I implement this? For instance, I would be stuck with how to draw a geometric number which is bounded on a specific support in Matlab. Then the "pieces" I get, I am not sure if should them store in arrays or not.
Thanks
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!