# Probability/Combinatorics

Often, in experiments with finite sample spaces, the outcomes are equiprobable. In such cases, the probability of an event amounts to the number of outcomes comprising this event divided by the total number of outcomes in the sample space. While counting outcomes may appear straightforward, it is in many circumstances a daunting task. For example, consider the number of distinct subsets of the integers {1, 2, ... , n} that do not contain two consecutive integers. This number is equal to

where is the *golden ratio*. It can also be obtained recursively through the *Fibonacci* recurrence relation.

Calculating the number of ways that certain patterns can be formed is part of the field of *combinatorics*. In this section, we introduce useful counting techniques that can be applied to situations pertinent to probability theory.

## Contents

## The Counting Principle[edit]

**The Fundamental Rule of Counting** If a set of choices or trials, T1, T2, T3, …, Tk, could result, respectively, in n1, n2, n3, …,nk possible outcomes, the entire set of k choices or trials has n1×n2×n3× … ×nk possible outcomes. (The numbers n1, n2, n3, …, nk cannot depend on which outcomes actually occur.)

By the Fundamental Rule of Counting, the total number of possible sequences of choices is 5×4×3×2×1 = 120 sequences. Each sequence is called a permutation of the five items. A permutation of items is an ordering of the items. More generally, by the Fundamental Rule of Counting, in ordering n things, there are n choices for the first, (n-1) choices for the second, etc., so the total number of ways of ordering a total of n things is n × (n-1) × (n-2) × . . . × 1. This product, n×(n-1)×(n-2)× . . . ×1, is written n!, which is pronounced "n factorial." By convention, 0! = 1

The counting principle is the guiding rule for computing the number of elements in a cartesian product as well.

The number of elements in the cartesian product S x T is equal to mn. Note that the total number of outcomes does not depend on the order in which the experiments are realized.

**Example:** Consider an experiment consisting of flipping a coin and rolling a die. There are two possibilities for the coin, heads or tails, and the die has six sides. The total number of outcomes for this experiment is 2 x 6 = 12. That is, there are twelve outcomes for the roll of a die followed by the toss of a coin: 1H, 1T, 2H, 2T, 3H, 3T, 4H, 4T, 5H, 5T, 6H, 6T.

The counting principle can be extended to compute the number of elements in the cartesian product of multiple sets. Consider the finite sets and their cartesian product

If we denote the cardinality of by , then the number of distinct ordered r-tuples of the form is .

**Example - Sampling with Replacement and Ordering:** An urn contains n balls numbered 1 through n. A ball is drawn from the urn, and its number is recorded on an ordered list. The ball is then replaced in the urn. This procedure is repeated k times. We wish to compute the number of possible sequences that results from this experiment. There are k drawings and n possibilities per drawing. Using the counting principle, we conclude that the number of distinct sequences is .

**Example:** The power set of S, denoted by , is the set of all subsets of S. In set theory, represents the set of all functions from S to {0, 1}. By identifying a function in with the corresponding preimage of one, we obtain a bijection between and the subsets of S. In particular, each function in is the characteristic function of a subset of S.

Suppose that S is finite with n = |S| elements. For every element of S, a characteristic function in is either zero or one. There are therefore distinct characteristic functions from S to {0, 1}. Hence, the number of distinct subsets of S is given by .

**Formulae** The formula for counting combinations has special cases that are worth memorizing: *nC0 = nCn = 1* (There is only one way to pick no thing and only one way to pick all n things.) *nC1 = nCn-1 = n* (there are n ways to pick one thing or to leave one thing out) *nCk = nCn-k* (There are the same number of ways of picking k of n things as there are of leaving out k of n things)

## Permutations[edit]

**Permutation:** an arrangement of objects without repetition where order is important. Permutations using all the objects: *n* objects, arranged into group size of *n* without repetition, and order being important. P(n, n) = N! Example: Find all permutations of A, B, C

Permutations of some of the objects: *n* objects, group size *r*, order is important. P(n, r) = N!/(n-r)! Example: Find all 2-letter combinations using letters A, B, C **Distinguished permutation:** if a word has *n* letters, *k* of which are unique, let *n* (n1, n2, n3....nk) be the frequency of each of the *k* letters: N!/(n1!)(n2!)(n3!).

Consider the integer set S = {1, 2, ... , n}. A *permutation* of S is an ordered arrangement of its elements, a list without repetitions. The number of permutations of S can be computed as follows. The number of distinct possibilities for the first item is n. The number of possibilities for the second item is n-1, namely all the integers in S except the first element in the list. Similarly, the number of distinct possibilities for the m-th item is n - m + 1. This pattern continues until all the elements in S are listed. Summarizing, we find that the total number of permutations of S is n *factorial,* n! = n (n-1) ... 1 .

**Example:** We wish to compute the number of permutations of S = {1, 2, 3}. Since the set S contains three elements, it has 3! = 6 permutations. They can be listed as 123, 132, 213, 231, 312, 321.

### Stirling's Formula[edit]

The number n! grows very rapidly as a function of n. A good approximation for n! when n is large is given by Stirling's formula,

as . The notation signifies that the ratio a(n)/b(n) approaches one as n tends to infinity.

### k-Permutations[edit]

Suppose that we list only k elements out of the set S = {1, 2, ... , n}, where . We wish to count the number of distinct k-permutations of S. Following our previous argument, we can choose one of n elements to be the first item listed, one of n-1 elements for the second item, and so on. The procedure terminates when k items have been listed. The number of possible sequences is

**Example:** A recently formed music group has four original songs they can play. They are asked to perform two songs at a music festival. We wish to compute the number of song arrangements the group can offer in concert. Abstractly, this is equivalent to computing the number of 2-permutations of four songs. Thus, the number of distinct arrangements is 4!/2! = 12.

**Example - Sampling without Replacement, with Ordering:** An urn contains n balls numbered one through n. A ball is picked from the urn, and its number is recorded on an ordered list. The ball is not replaced in the urn. This procedure is repeated until k balls are selected from the urn, where . We wish to compute the number of possible sequences that results from this experiment. The number of possibilities is equivalent to the number of k-permutations of n elements, which is given by n!/(n-k)!.

## Combinations[edit]

**Combinations**: arrangement of objects without repetition, where order is NOT important. A combination of *n* objects, arranged in groups of size *r*, without repetition, and order being important. C(n, r) = n!/r!(n-r)! Another way to write a combination of *n* things, *r* at a time, is using the Binomial notation (**Binomial Distribution**). Combinations of this type are referred to verbally as "n choose r".

Consider the integer set S = {1, 2, ... , n}. A *combination* is a subset of S. We emphasize that a combination differs from a permutation in that elements in a combination have no specific ordering. The 2-element subsets of S = {1, 2, 3, 4} are {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4} , whereas the 2-permutations of S are more numerous with (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3) . There are therefore fewer 2-element subsets of S than 2-permutations of S.

We can compute the number of k-element combinations of S = {1, 2, ... , n} as follows. First, we note that a k-permutation can be formed by first selecting k objects from S and then ordering them. There are k! distinct ways of ordering k objects. The number of k-permutations must then equal the number of k-element combinations multiplied by k!. Since the total number of k-permutations of S is n! / (n-k)!, the number of k-element combinations is found to be

This expression is called a *binomial coefficient*. Observe that selecting a k-element subset of S is equivalent to choosing the n-k elements that belong to its complement.

**Example - Sampling without Replacement or Ordering:** An urn contains n balls numbered one through n. A ball is drawn from the urn and placed in a jar. This process is repeated until the jar contains k balls, where . We wish to compute the number of distinct combinations the jar can hold after the completion of this experiment. Because there is no ordering in the jar, this amounts to counting the number of k-element subsets of a given n-element set, which is given by

Again, let S = {1, 2, ... , n}. Since a combination is also a subset and the number of k-element combinations of S is , the sum of the binomial coefficients over all values of k must be equal to the number of elements in the power set of S. Thus, we get

## Partitions[edit]

Abstractly, a combination is equivalent to partitioning a set into two subsets, one containing k objects and the other containing the n-k remaining objects. In general, the set S = {1, 2, ... , n } can be partitioned into r subsets. Let be nonnegative integers such that

Consider the following iterative algorithm that leads to a partition of S. First, we select a subset of elements from S. Having chosen the first subset, we select a second subset containing elements from the remaining elements. We continue this procedure by successively choosing subsets of elements from the remaining elements, until no element remains. This algorithm yields a partition of S into r subsets, with the p-th subset containing exactly elements.

We wish to count the number of such partitions. We know that there are ways to form the first subset. Examining our algorithm, we see that there are

ways to form the p-th subset. Using the counting principle, the total number of partitions is then given by

This expression is called a *multinomial coefficient*.

**Example:** A die is rolled nine times. We wish to compute the number of outcomes for which every odd number appears three times. The number of distinct sequences in which one, three, and five each appear three times is equal to the number of partitions of {1, 2, ... , 9} into three subsets of size three, namely

In the above analysis, we assume that the size of each subset is fixed, three subsets of size three. Suppose instead that we are interested in counting the number of ways of picking the sizes of the subsets, r subsets of size, where the sum of the sizes is a constant. Specifically, we wish to compute the number of ways integers can be selected such that every integer is nonnegative and

.

We can visualize the number of possible assignments as follows. Picture n balls spaced out on a straight line and consider r-1 vertical markers, each of which can be put between two consecutive balls, before the first ball, or after the last ball. For instance, if there are five balls and two markers then one possible assignement is illustrated below.

The number of objects in the first subset corresponds to the number balls before the first marker. Similarly, the number of objects in the p-th subset is equal to the number of balls between the p-th marker and the preceding one. Finally, the number of objects in the last subset is simply the number of balls after the last marker. In the figure, the integer assignment is

Two consecutive markers imply that the corresponding subset is empty. There is a natural bijection between an integer assignment and the graphical representation depicted above. To count the number of possible integer assignments, it then suffices to compute the number of ways to position the markers and the balls. In particular, there are n + r - 1 positions, n balls, and r - 1 markers. The number of ways to assign the markers is equal to the number of n-combinations of n + r - 1 elements,

**Example - Sampling with Replacement, without Ordering:** An urn contains r balls numbered one through r. A ball is drawn from the urn and its number is recorded. The ball is then returned to the urn. This procedure is repeated a total of n times. The outcome of this experiment is a table that contains the number of times each ball has come in sight. We are interested in computing the number of distinct outcomes. This is equivalent to counting the ways a set with n elements can be partitioned into r subsets. The number of possible outcomes is therefore given by

## Computing Probabilities[edit]

In this section, we present two straightforward applications of combinatorics to computing the probability of winning the lottery.

**Example - Pick 3 Texas Lottery:** The Texas Lottery game *Pick 3* is easy to play. A player must pick three numbers from zero to nine, and choose how to play them: exact order, or any order. The Pick 3 balls are drawn using three air-driven machines. These machines use compressed air to mix and select each ball.

The probability of winning while playing the exact order is

The probability of winning while playing any order depends on the numbers selected. If three distinct numbers are selected then the probability of winning is 3/500. If a number is repeated twice, the probability of winning is 3/1000. While, if the same number is selected three times, the probability of winning becomes 1/1000.

**Example - Mega Millions Texas Lottery:** To play the Mega Millions game, a player must select five numbers from 1 to 56 in the upper white play area of the play board, and one Mega Ball number from 1 to 46 in the lower yellow play area of the play board. All drawing equipment is stored in a secured on-site storage room. Only authorized drawings department personnel have keys to this door. Upon entry of the secured room to begin the drawing process, a lottery drawing specialist examines the security seal to determine if any unauthorized access has occurred. For each drawing, the Lotto Texas balls are mixed by four acrylic mixing paddles rotating clockwise. High speed is used for mixing and low speed for ball selection. As each ball is selected, it rolls down a chute into an official number display area. We wish to compute the probability of winning the Mega Millions Grand Prize, which require the correct selection of the five white balls plus the gold Mega ball. The probability of winning the Mega Millions Grand Prize is