Graph cumulative sum against percentage

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 Kommentare

the cyclist
the cyclist am 3 Sep. 2013
My advice is that since this sounds like a homework problem, you post your code showing some evidence that you tried yourself. Then maybe someone will give you a hint, without just doing your work for you.
Brian
Brian am 3 Sep. 2013
I just don't know how to do a graph of the percentage that are 6 against the number of throws, since the vector size is different every time.
Image Analyst
Image Analyst am 4 Sep. 2013
x is the number of throws, so you're doing it right, at least in the first plot. I have no idea what f is in the second plot since you didn't assign it.
Brian
Brian am 4 Sep. 2013
(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 am 4 Sep. 2013
OK - ignore the second plot. So why isn't the first plot what you want?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Sep. 2013

0 Stimmen

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

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by