Template:DrawChance

This template calculates the chance of drawing any of x cards out of y total possibilities in z chances, without replacement, as a percentage, where x y and z are the inputs to this template in order. The alias DiscoverChance can be used for listing the chance of Discovering a certain option, which is the same as just setting z to 3 for the same result.

"Without replacement" means that the effect cannot choose the same option twice. Discover, for instance, always presents different options. Cabalist's Tome, on the other hand, can generate multiples of the same card.

This template is most useful when one of the components changes from time to time, such as y (the number of options) becoming larger as more cards are added to a certain card pool. A query for the number of cards in the pool can be passed into this template, which then calculates the correct percentage based on the query result instead of requiring pre-calculation.

This can be used for more than just cards, for instance the chance of Adapt or Sir Finley Mrrgglton presenting desirable adaptations or Hero Powers, respectively.

Parameters

 * 1) "x" - The number of desired choices.
 * 2) "y" - The total number of choices the effect is drawing from.
 * 3) "z" - The number of chances to draw a desired choice. Must be between 1 and 6, although the template could be modified to support more. If not specified, defaults to 1. Use DiscoverChance to default to 3.
 * 4) "p" - Decimal places to round to. If not specified, defaults to 1 decimal place, but 2 might be desirable for comparing very low chances. The wiki calculator will automatically avoid printing 0s in decimal places if it's an exact integer.

Examples

 * produces "".
 * 1 spell out of 5 left in the deck with Shadow Visions.
 * produces "".
 * 1 spell out of 31 available in standard format with Primordial Glyph.
 * produces "".
 * 2 "outs" on the next draw to defend against the opponent's lethal on the board, with 6 cards left in the deck.
 * produces "".
 * Any of 4 Hero Powers out of 8 offered by Sir Finley Mrrgglton.

Math
When only 1 card is desired over several chances, or there is only 1 chance to draw one of several cards, then the probability is a simple single fraction, a/b, where b is the total number of options, and a is either the number of desirable cards for a single draw, or the number of chances to draw a single card. In other words, if you draw 1 card, there's an a/b chance of that 1 being one of "a" cards you wanted. If you draw "a" cards, there's an a/b chance that the 1 you wanted was among the "a" you drew.

When one of several cards is desired, and there are multiple chances to draw, it becomes more complicated. This is most easily calculated by finding the chance to fail to draw any of the desired cards, then subtracting that from 100% to find the chance to succeed. The chance for failure gains another fractional factor with each draw chance, each one equal to "number of failure cards left"/"total number of cards left", with both numerator and denominator decreasing by 1 every time as more and more failure cards are drawn.

Example:
 * Chance to Discover neither of 2 cards in 3 chances out of 30: 28/30 * 27/29 * 26/28 = 27*26/(30*29) = 80.69%.
 * Chance to Discover one or both of 2 cards in 3 chances out of 30: 1 - the above calculation = 19.31%.
 * 1 - = 1 -  = 80.69%