Title: Is it Yahtzee
1Is it Yahtzee?
Exploring Probability with Dice
2YahtzeeProbability Times 3
AIS Summer Teacher Institute June 2002
- James Jacobs
- Rebecca Raulie
- Ron Saucier
- Elvira Crockett
3What is the Probability of Rolling 3 Dice the
Same?
- In 1 Roll ?
- In 2 Rolls ?
- In 3 Rolls ?
4Probability
1 Roll 2.77
2 Rolls 11.26
3 Rolls 21.68
5(No Transcript)
6import UserInput public class Yahtzee public
static void main (String args) double
a,b,c double success0 double
prob for(int i1 ilt10000 ii1) a1(int)(M
ath.random()6) b1(int)(Math.random()6) c1
(int)(Math.random()6) if(ab
bc) successsuccess1 System.out.print(
a) System.out.print(b) System.out.print(c) S
ystem.out.println() System.out.println("suc
cess"success) prob(success100)/10000 Syste
m.out.println("prob") System.out.println(prob)
System.exit (0)
Java Program 3 Dice One Roll
7Why Study Probability?
8Its All Just a Roll of the Dice!!
9(No Transcript)
10(No Transcript)
11(No Transcript)
12mport UserInput public class Yahtzee2 public
static void main (String args) double
a,b,c,d,e,f,g double success0 double
prob for(int i1 ilt2000i00
i) a1(int)(Math.random()6) b1(int)(Math
.random()6) c1(int)(Math.random()6) if(a
b bc) successsuccess1 else
if(ab ac bc) d1(int)(Math.r
andom()6) if(ad bd) successsucce
ss1 else e1(int)(Math.random()6)
f1(int)(Math.random()6) g1(int)(Math.
random()6) if(ef fg) success1
System.out.print(a) System.out.print(b)
System.out.print(c) System.out.println()
System.out.println("success"success) prob(suc
cess100)/200000 System.out.println("prob") Sy
stem.out.println(prob) System.exit (0)
2 Rolls
13Now for the second roll Case 1 given that 2 were
same from 1st roll we want Prob (1st roll 2
same) Prob (new roll matches) 90/216
1/6 Prob(Case 1
roll2).069 Case 2 given that all three
different from 1st roll we want Prob (1st roll
different) Prob (new roll all 3 same) 120/216
6/216 Prob (case 2 roll2)
.0154 note that Prob (A and B)P(A)P(B) -------
--------------------------------------------------
------------- Conclusion We add the prob(all 3
same on 1st roll) prob( 2same on 1st
rollmatch on second) prob (all diff on 1st
roll 3 same on second roll) .027777.06944.0154
.112617 or 11.26 prob. of success within 2
rolls. The Computer simulation Yahtzee and
Yahtzee2 matched perfectly. The main math models
are Prob (A and B)P(A)P(B) P(A or B) P(A
U B) P(A) P(B) for mutually exclusive events
14(No Transcript)
15Logic error.txt
Aside Programming Note When we ran
Yahtzee2, which finds the prob. of getting all
three die the same within two rolls (where you
could keep two from the first roll if they were
the same) the program indicated a 15.8 prob.
When I used the formulas to calculate the prob. I
came up with 11.261 prob. At first I thought I
had made a mistake with the formulas and trusted
the computer but after reworking the problem, I
went back to the code. I found a logical error
when finding the case where two die were the
same on the first roll and the second roll gave a
third die that matches. I had if(ad or bd)
then add 1 to the success counter. D is the 4th
random number representing the new roll on try
2. The problem is that a or b could have been the
third die that was not the same as the other
two. I corrected the line to read if(ab
ad) then success and listed all three cases.
if(ac ad) and if(bc bd) The
interesting point to me is that we used a formula
to predict what the computer simulation should
give us and when it didn't we could recognize
that we had a problem either in the program or
the math model (or solving the math model).