How to Use

Parameters

The odds of drawing a specific card is modeled using the hypergeometric distribution, and using it requires the following parameters:

Here is a table of the numbers one would use to calculate the odds of drawing a card by turn 3 in some card games:

TCG NameDeck sizeHand sizeDraws (1st)Draws (2nd)
Cardfight! Vanguard50546
Magic: the Gathering (EDH)99733
Flesh and Blood 160468
Yu-Gi-Oh!40523
Grand Archive60723

Desired range

Definition

A success is a card we’re interested in knowing the probability of drawing. Cards in the deck are segregated into either successes or failures.

In addition to the parameters above, you also need to specify how successes you want in your hand. This is done with the Minimum (XminX_{\min{}}) and Maximum (XmaxX_{\max{}}) parameters. Consider the following examples:

The interval [Xmin,Xmax][X_{\min{}}, X_{\max{}}] is the desired number of successes. Consider what the ideal amount you would want to draw is when choosing these numbers.

Statistics

Unlike most hypergeometric calculators, which require you to enter how many successes you already play, this calculator generates a table for every possible number of successes! You can compare and contrast different ratios at your leisure.

In that table you’ll find the following:

Example

In Yu-Gi-Oh, you build a 40-card deck, play with a five-card starting hand, and only draw one card going second. Say we wanted to find the probability of drawing exactly one copy of a card by turn 1. The parameters and corresponding outputs should look like this:

Deck size40Hand size5
Draws (1st)0Draws (2nd)1
Minimum (XminX_{\min{}})1Maximum (XmaxX_{\max{}})1
Undesired cards0
Yu-Gi-Oh! example inputs
#Pr(1)\Pr(1)MeanPr(XX\geq 1)Mode
541.037%0.68854.188%0
642.892%0.82561.337%1
743.407%0.96367.538%1
842.845%1.10072.894%1
941.438%1.23877.498%1

Here’s how to read it:

The Cardfight!! Vanguard Mulligan

Cardfight!! Vanguard has a unique mulligan: you start the game by drawing five cards, then you may choose any number of cards in that hand to put onto the bottom of the deck and draw the same amount. The fact the deck is shuffled after the mulligan, along with one-third of a deck is composed of triggers, adds an extra level of complexity to the odds of drawing a card.

Definition

An undesired card is any card in the deck which one would return in the mulligan. Triggers are usually undesired card, but any card which one would not want to keep is considered undesired.

The calculator assumes three distinct card types:

For any game which does not have the same mulligan as Vanguard, set Undesired cards to 0. This forces the calculator to function as if there were no mulligan at all, as there would only be two card types in the deck: successes and non-successes.

Example

Rancor Chain
How many orders should we play for Rancor Chain?

Rancor Chain is one of the few ride deck cards which can be played in any «Stoicheia» deck. While it doesn’t require a specific ride line, it does ask the player to dedicate some deck space for orders. We should run enough orders so that Rancor Chain “always” has an order to discard; but too many orders will leave our early-game hand lacking in shield and board presence.

Deck size50Hand size5
Draws (1st)3Draws (2nd)4
Minimum (Xmin)(X_{\min{}})1-2Maximum (Xmax)(X_{\max{}})1-2
Undesired cards16
Rancor Chain inputs
#Pr(1)\Pr(1)Pr(1,2)\Pr(1,2)Pr(2)\Pr(2)Mode
443.227%58.453%15.226%1
*5*43.498%64.570%21.072%1
641.755%67.863%26.108%1
*738.707%*68.728%30.022%1
834.898%67.581%32.683%1
930.738%64.829%34.092%2
*1026.522%60.862%*34.340%2
1122.458%56.036%33.578%2

Assuming we put any triggers we see back to deck, we draw 3 cards going first (1 per turn, 2 from Rancor Chain itself), and draw 4 cards going second, we get these probabilities. Going column by column:

10 orders seems like the most one would want to run to make use of Rancor Chain. 7 is probably a good lower limit, since that maximizes drawing either one or two orders which are both good outcomes.

Let’s also look at how likely it is to draw at least one order, or Pr(X1)\Pr(X \geq 1), both with and without the mulligan:

#Pr. with mulliganPr. w/o mulligan
120.011%17.000%
236.396%31.388%
349.741%43.520%
460.547%53.713%
569.247%62.241%
676.206%69.346%
781.736%75.241%
886.098%80.109%

With 16 triggers to put back, there’s a roughly 3-7% increase in the odds of drawing an order with the mulligan than without; that gap is the widest at 5 orders with a difference of 7.006%. Pretty substantial! Now we know the exact effect that Vanguard’s generous mulligan has on consistency.

How does it work?

There are two factors which muddy the calculations:

  1. How many cards are drawn for the mulligan is determined by how many undesired cards are drawn pre-mulligan.
  2. Undesired cards are shuffled back into the deck post-mulligan.

Think of how you would calculate the odds of drawing exactly one success by turn 2. The probability is 0 if you already have one or more successes in hand; if you don’t, it depends entirely on your draws on turn 1 and turn 2. If we wanted to know the odds of drawing exactly two successes, we would have three cases: where we drew no successes, where we drew one success, and where we drew two.

Pre-mulligan handPr(k0)Post-mulligan handPr(k1k0)Hand after drawsPr(k2k1)\underbrace{\text{Pre-mulligan hand}}_{\Pr(k_0)} \rightarrow \underbrace{\text{Post-mulligan hand}}_{\Pr(k_1 | k_0)} \rightarrow \underbrace{\text{Hand after draws}}_{\Pr(k_2 | k_1)}

Rather than use one hypergeometric distribution, we consider three. k0k_0 is the number of successes drawn pre-mulligan; k1k_1 is the number of successes post-mulligan; and k2k_2 is the number of successes after in-game draws. k2k_2 is the variable we are interested in, but it is dependent on k1k_1 and k1k_1 is dependent on k0k_0. Using conditional probabilities, we can write the full expression like this:

Pr(k2)=k1=05Pr(k2k1)Pr(k1)=k1=05[Pr(k2k1)0k050t5Pr(k1k0,t)Pr(k0,t)]\Pr(k_2)=\sum^5_{k_1=0}\Pr(k_2 |k_1)\Pr(k_1)=\sum^5_{k_1=0}\left[\Pr(k_2 |k_1)\cdot\sum_{\substack{0 \leq k_0 \leq 5 \\ 0 \leq t \leq 5}}\Pr(k_1|k_0, t)\Pr(k_0, t)\right]

where

Pr(k0,t)=(Kk0)(Tt)(50k0t5k0t)(505),Pr(k1k0,t)=(Kk0k1k0)(45K+k0t+k0k1)(45t),Pr(k2k1)=(Kk1k2k1)(45K+k2n+k1k2)(45n)\Pr(k_0, t) = \frac{{K \choose k_0}{T \choose t}{50 - k_0 - t \choose 5 - k_0 - t}} {50 \choose 5}, \Pr(k_1 | k_0,t) = \frac{{K - k_0 \choose k_1 - k_0}{45 - K + k_0 \choose t + k_0 - k_1}} {45 \choose t}, \Pr(k_2 | k_1) = \frac{{K - k_1 \choose k_2 - k_1}{45 - K + k_2 \choose n + k_1 - k_2}} {45 \choose n}

tt is the number of undesired cards drawn, TT is the number of undesired cards in deck, and nn is the number of post-mulligan draws.

This is a pretty messy expression, but easy to automate. The calculator uses a simple for loop to find the “prior” distribution. Assuming 10 of the desired card are played:

const priors = [];
for(var k_post = 0; k_post <= 5; k_post++){
    for(var trigger = 0; trigger <= 5; trigger++) {
        for(var k_pre = 0; k_pre <= k_post; k_pre++) {
            const p_prior = multigeodist(
                k_pre, 10, 
                trigger, 16,
                5, 50
            );
            const p_post = hypgeodist(
                k_post - k_pre, 10 - k_pre,
                trigger, 45
            );
            priors.push(p_prior * p_post);
        }
    }
}

With this prior distribution as a base, we can calculate the odds of drawing k2k_2 successes after the mulligan pretty easily.

Footnotes

  1. Assuming a hero with 4 intellect, and two cards are played / pitched during the turn for both players.

  2. Pardon the abuse of notation. Formally, this would be written Pr(XminXXmax)\Pr(X_{\min{}} \leq X \leq X_{\max{}}) or Pr(X[Xmin,Xmax])\Pr(X \in [X_{\min{}}, X_{\max{}}]), but given the context of the calculator the abbreviation was apt.