Graph cumulative sum against percentage

조회 수: 7 (최근 30일)
Brian
Brian 2013년 9월 3일
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
Brian
Brian 2013년 9월 4일
(Ignore f), I just want to do a graph of the percentage of throws which add up to 6 kinda over time in a sense, if we imagine each set of thrrows is one second.
When I tried I couldn't get it to work, the f was left over from when I tried
Image Analyst
Image Analyst 2013년 9월 4일
OK - ignore the second plot. So why isn't the first plot what you want?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
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개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by