| DEAL(1) | DEAL(1) |
NAME¶
deal - compute and display deal probabilities
SYNOPSIS¶
deal [-h] [-b base] [-t turns] [-c columns] [-q] [-w] special total
DESCRIPTION¶
This program prints out tables of non-replacement draw probabilities, rounded to the nearest percent.
Suppose I have M special cards in my deck and N total cards in my deck, and I draw k cards from that deck without replacement. Let X count the number of special cards contained in those k drawn cards.
Then X has a hypergeometric distribution, with the following formula for probabilities:
B(M, i) * B(N-M, k-i)
P(X = i) = ---------------------
B(N, k) ---
where B(a,b) is the binomial coefficient (read "a choose b"), and is the number of ways to choose b objects out of a possible objects. The formula for the binomial coefficient is:
B(n,m) = n!/(m! * (n-m)!)
where n! is the factorial function n! = 1 * 2 * 3 * ... * n.
This program prints out tables of these probabilities. The specials and total arguments specify M and N. The table displays values for ranges of k and i.
In the table output, a dot designates a probability less than .5% that rounds to zero. Impossible outcomes are blank.
The program accepts the following options to control its output:
-b base
-g
-w
-c columns
-h
-t draws
-v
-B
-G
-H
EXAMPLES¶
To compute the probabilities for drawing your 3 Hurloon Minotaurs during the first 20 turns from a 62-card "Magic: The Gathering" deck (MtG starts you with 7 cards):
deal 3 62
To compute your chances of having the 4 aces on the nth draw in 5-card draw poker:
deal -b 5 4 52
BUGS¶
The -w and -g options widen the column width of the tables to accommodate 100% probabilities, at the cost of making the table too wide to display on an 80-column terminal when the number of specials is more than 17. When wide display is off, on the other hand, 23 specials will fit in 80 colums, but 100% probabilities can mess up the table formatting.
AUTHOR¶
Eric S. Raymond <esr@snark.thyrsus.com>. Based on the "cardprobs" program by Jeremy York. See my home page at <http://www.catb.org/~esr> for updates and other resources.
| 2024-02-08 |