Thread: Lottery...
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Lottery...

On May 31, 3:43*am, "Jake" wrote:
Essentially I need to write this in a formula that will
calculate the chances of getting [say] 3 numbers correct
when you draw five balls from a pot of 10, and this formula
will work to calculate the chances of getting X numbers
correct when you draw Y balls from a set of Z size.


..... Where X is C2, Y is B2 and Z is A2 in your original question.
Try the folowing in D2:

=COMBIN($A$2-$B$2,$B$2-C2)*COMBIN($B$2,C2)

Suppose A2 is 56 and B2 is 5. I wrote the formula above so that you
can put 0 through 5 (B2) into C2 through C7, and copy the formula down
through D7. Then, as a check, SUM(D2:D7) should equal the total
number of ways to choose 5 from 56, namely COMBIN(A2,B2).

Explanation: In a set of B2, COMBIN(B2,C2) is the number of ways to
match C2. Then, COMBIN(A2-B2,B2-C2) is the number of ways that the
remainder of the set, B2-C2, does not match any of the B2 numbers
drawn; that is, matches the remainder of the set drawn from, A2-B2.

Computational note: Mathematically, COMBIN(n,k) is computed by
FACT(n)/(FACT(k)*FACT(n-k)). Since Excel uses binary floating-point
to represent numbers and to do computation, Excel can represent only
integers up to 2^53 exactly. Thus, obstensibly, FACT(17) is the
largest factorial that we can be sure is calculated accurately. In
fact, larger factorials can be calculated accurately, by coincidence.
And there are ways to compute COMBIN so as to extend the range of
accuracy.

But the point is: for some combination of A2 and B2, the sum of the
formula above (D2) might not exactly equal COMBIN(A2,B2).