Implementing a Simple Algorithm with Loops
1 回表示 (過去 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!