Saturday, April 13, 2019

Summation formulas for multivariate hypergeometric

Frank Karsten taught me several things with his recent article on Magic applications of the multivariate hypergeometric distribution.  Deck-u-lator has always been clear that this is the math formula we are calculating.  Frank includes summations over variables to account for the difference between the cards specified in the combination and how many cards are being drawn.
\sum_{ C_0=1 }^{4} \sum_{ C_1=1 }^{4} \sum_{ C_2=1 }^{\min(4,10-C_0-C_1)}\frac{{\binom{4}{C_0} \binom{4}{C_1} \binom{4}{C_2} \binom{48}{10-C_0-C_1-C_2}}}{{\binom{60}{10}}} = 12.6\%
Summations over variables in multivariate hypergeometric distribution
When implementing Deck-u-lator, I thought through the allocation of these extra cards using recursive functions.  Frank's formula examples were the first time I noticed summations with hypergeometric distribution.  As he says, once you know the formula, you can implement it a variety of ways using a spreadsheet or a programming language.

I ran all Frank's examples through Deck-u-lator as test cases and compared the calculated results to formula results.  Here is one of the test case formulas in Python.

sum(sum(sum(choose(4,m)*choose(4,p)*choose(4,t)*choose(48,10-m-p-t)
            / choose(60,10)
            for t in span(1,max(4,10-m-p))
        for p in span(1,4))
    for m in span(1,4))

Since I found the formulas so helpful, I thought I would start generating them in Deck-u-lator and maybe others will also find them helpful.
$$ \sum_{ C_0=1 }^{4} \sum_{ C_1=1 }^{4} \sum_{ C_2=1 }^{\min(4,10-C_0-C_1)}\frac{{\binom{4}{C_0} \binom{4}{C_1} \binom{4}{C_2} \binom{48}{10-C_0-C_1-C_2}}}{{\binom{60}{10}}} = 12.6\% $$

No comments:

Post a Comment