Graph cumulative sum against percentage
6 ビュー (過去 30 日間)
古いコメントを表示
I want a graph of the cumulative percentage of two random dices that add up to 6 as a percentage of the total throws (in the subplot (2,1,2).
Any advice would be great.
5 件のコメント
Image Analyst
2013 年 9 月 4 日
OK - ignore the second plot. So why isn't the first plot what you want?
採用された回答
Image Analyst
2013 年 9 月 3 日
Use randi() and plot(). Put in a loop over a million iterations if you want to do a Monte Carlo Simulation. It's just basic programming.
numberOfThrows = 1000000
die1 = randi(6, [numberOfThrows, 1]);
die2 = randi(6, [numberOfThrows, 1]);
sixCount = 0;
for t = 1 : numberOfThrows
thisThrow1 = die1(t);
thisThrow2 = die2(t);
theSum = thisThrow1 + thisThrow2;
if theSum == 6
sixCount = sixCount + 1;
% etc. - I'm sure you can finish it.
end
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Performance and Memory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!