0% found this document useful (0 votes)
164 views

Counting Probability of Dice Tossing One Two and Three in Matlab

This document discusses using Matlab code to calculate the probabilities of rolling one, two, and three dice. For one die, the code generates a distribution of the probabilities of each number appearing. For two dice, it calculates the probabilities of the sums of each roll. For three dice, it similarly calculates the probabilities of the sums of each possible roll. The code includes results for one, two, and three dice rolls.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
164 views

Counting Probability of Dice Tossing One Two and Three in Matlab

This document discusses using Matlab code to calculate the probabilities of rolling one, two, and three dice. For one die, the code generates a distribution of the probabilities of each number appearing. For two dice, it calculates the probabilities of the sums of each roll. For three dice, it similarly calculates the probabilities of the sums of each possible roll. The code includes results for one, two, and three dice rolls.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4

[sharing is caring]

COUNTING PROBABILITY of DICE TOSSING ONE TWO and THREE in Matlab

Well, this is article was written to accomodate my curiosity to find the probability of tossing one to three dices simultanously. There is no need further explanation about how it works or probability theory. I believe one will understand in short times. Take a look at the codes below including the results. One and two dices Codes
clear; clc; A=[1,2,3,4,5,6]; PA=ones(1,6); % jumlah kemunculan untuk 1 buah dadu figure(1) stem(A,PA) axis([1 6 0 2]); xlabel('Sisi Yang Muncul'); ylabel('Jumlah Kemunculan'); title('Distribusi Peluang Kemunculan Pada 1 Dadu'); % jumlah kemunculan untuk 2 buah dadu for n=0:5 B(n+1,:)=A+A(6-n); end B = sort(reshape(B,1,36)); k=1; m=1; while k<=36 jum=length(find(B==m)); jumP(m,:)=jum; m=m+1; k=k+jum; end figure(2) stem(1:12,jumP); axis([1 12 0 7]); xlabel('Penjumlahan Sisi-sisi Yang Muncul'); ylabel('Jumlah Kemunculan'); title('Distribusi Peluang Kemunculan Pada 2 Dadu');

[jans hendry / ee&it UGM, Indonesia]

Page 1

[sharing is caring]

result

Three dices
Page 2

[jans hendry / ee&it UGM, Indonesia]

[sharing is caring]

Codes
clear; clc; A=[1,2,3,4,5,6]; % jumlah kemunculan untuk 3 buah dadu k=1; m=1; while k<=36 for n=1:6 for l=1:6 B(n,l)=A(m)+A(n)+A(l); end end C(k:k+5,:)=B; k=k+6; m=m+1; end kl=1; ml=1; while kl<=216 jum=length(find(C==ml)); jumP(ml,1)=jum; ml=ml+1; kl=kl+jum; end stem(1:18,jumP) axis([2 20 0 30]); xlabel('Penjumlahan Sisi-sisi Yang Muncul'); ylabel('Jumlah Kemunculan'); title('Distribusi Peluang Kemunculan Pada 3 Dadu');

[jans hendry / ee&it UGM, Indonesia]

Page 3

[sharing is caring]

result

~~~ terima kasih ~~~

[jans hendry / ee&it UGM, Indonesia]

Page 4

You might also like