Lecture 6 Tutorial 2 Matlab
Lecture 6 Tutorial 2 Matlab
https://www.blackjackinfo.com/knowledge-base/blackjack-theory-and-
math/a-question-for-the-statistics-experts/
http://math.stackexchange.com/questions/598808/if-you-roll-a-fair-six-
sided-die-twice-whats-the-probability-that-you-get-the
or equivalently:
x = [3 ; 2 ; 1]
Dr. Faisal Bukhari, Department of Data
5
Science, PU, Lahore
Relational operators
The relational operators in MATLAB are:
| or
~ not
|| short-circuit or
ans =
5
>> fix(5.9)
ans =
5
n=
Columns 1 through 6
8 9 1 9 6 0
Columns 7 through 10
2 5 9 9
totalNumberOfHeads =
sum(headsOutOf1000);
probabilityOfHeads = totalNumberOfHeads
/1000;
D5 = SumOfDice == 5;
D6 = SumOfDice == 6;
D7 = SumOfDice == 7;
D9 = SumOfDice == 9;
probD1 = 0;
p = [probD1 , probD2, probD3, probD4,
probD5, probD6, probD7, probD8,
probD9, probD10, probD11, probD12 ]';
bar(p)
hold on
xlabel('Sum of two dice')
ylabel('Probability')