title: Combinatorics Counting Puzzle: Roll 20, 8-sided dice, what is the probability of getting at least 5 dice of the same value
body: <p>Assume a game in which one rolls 20, 8-sided die, for a total number of 8^20 possible outcomes. To calculate the probability of a particular event occurring, we divide the number of ways that event can occur by 8^20. </p>
  
  <p>One can calculate the number of ways to get exactly 5 dice of the value 3. (20 choose 5) gives us the number of orders of 3. 7^15 gives us the number of ways we can not get the value 3 for 15 rolls.</p>
  
  <pre><code>number of ways to get exactly 5, 3's = (20 choose 5)*7^15.
  </code></pre>
  
  <p>The answer can also be viewed as how many ways can I rearrange the string 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 (20 choose 5) times the total number of values we the zero's (assuming 7 legal values) 7^15 (is this correct).</p>
  
  <ul>
  <li><p>Question 1: How can I calculate the number of ways to get exactly 5 dice of the same value(That is, for all die values).
  Note: if I just naively use my first answer above and multiply bt 8, I get an enormous amount of double counting?</p>
  
  <p>I understand that I could solve for each of the cases (5 1's), (5, 2's), (5, 3's), ... (5's, 8) sum them (more simply 8*(5 1's) ). Then subtract the sum of number of overlaps (5 1's) and (5 2's), (5 1's) and (5 3's)... (5 1's) and (5, 2's) and ... and (5, 8's) but this seems exceedingly messy. I would a generalization of this in a way that scales up to large numbers of samples and large numbers of classes.</p></li>
  <li><p>How can I calculate the number of ways to get <strong>at least</strong> 5 dice of the same value?</p>
  
  <p>So 111110000000000000000 or 11110100000000000002 or 11111100000001110000 or 11011211222222223333, but not 00001111222233334444 or 000511512252363347744.</p></li>
  </ul>
  
  <p>I'm looking for answers which either explain the math or point to a library which supports this (esp python modules). Extra points for detail and examples.</p>