1 / 15

Is it Yahtzee?

Is it Yahtzee?. Exploring Probability with Dice. Yahtzee Probability Times 3. James Jacobs Rebecca Raulie Ron Saucier Elvira Crockett. AIS Summer Teacher Institute June 2002. What is the Probability of Rolling 3 Dice the Same?. In 1 Roll ? In 2 Rolls ? In 3 Rolls ?. Probability .

neena
Download Presentation

Is it Yahtzee?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Is it Yahtzee? Exploring Probability with Dice

  2. YahtzeeProbability Times 3 James Jacobs Rebecca Raulie Ron Saucier Elvira Crockett AIS Summer Teacher Institute June 2002

  3. What is the Probability of Rolling 3 Dice the Same? • In 1 Roll ? • In 2 Rolls ? • In 3 Rolls ?

  4. Probability 1 Roll = 2.77 % 2 Rolls = 11.26 % 3 Rolls = 21.68%

  5. import UserInput; public class Yahtzee { public static void main (String args[]) {double a,b,c; double success=0; double prob; for(int i=1; i<=10000; i=i+1){ a=1+(int)(Math.random()*6); b=1+(int)(Math.random()*6); c=1+(int)(Math.random()*6); if(a==b && b==c) success=success+1; System.out.print(a); System.out.print(b); System.out.print(c); System.out.println(); } System.out.println("success"+success); prob=(success*100)/10000; System.out.println("prob"); System.out.println(prob); System.exit (0); } } Java Program 3 Dice One Roll

  6. Why Study Probability?

  7. It’s All Just a Roll of the Dice!!

  8. mport UserInput; public class Yahtzee2 { public static void main (String args[]) {double a,b,c,d,e,f,g; double success=0; double prob; for(int i=1; i<=2000i00; i++){ a=1+(int)(Math.random()*6); b=1+(int)(Math.random()*6); c=1+(int)(Math.random()*6); if(a==b && b==c) success=success+1; else if(a==b || a==c || b==c) {d=1+(int)(Math.random()*6); if(a==d || b==d) success=success+1;} else {e=1+(int)(Math.random()*6); f=1+(int)(Math.random()*6); g=1+(int)(Math.random()*6); if(e==f && f==g) success+=1;} System.out.print(a); System.out.print(b); System.out.print(c); System.out.println();} System.out.println("success"+success); prob=(success*100)/200000; System.out.println("prob"); System.out.println(prob); System.exit (0); } } 2 Rolls

  9. Now 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 roll+match 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

  10. Logic 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(a==d or b=d) 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(a==b && a=d) then success and listed all three cases. [if(a==c && a=d) and if(b=c && b=d)] 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).

More Related