# 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 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, , could result, respectively, in possible outcomes, the entire set of choices or trials has possible outcomes. (The numbers cannot depend on which outcomes actually occur.)

By the Fundamental Rule of Counting, the total number of possible sequences of choices is 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 things, there are choices for the first, choices for the second, etc., so the total number of ways of ordering a total of things is . This product is written , which is pronounced "n-factorial." By convention,

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 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 . That is, there are twelve outcomes for the roll of a die followed by the toss of a coin:

- .

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 balls numbered . 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 times. We wish to compute the number of possible sequences that results from this experiment. There are 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 . In set theory, represents the set of all functions . By identifying a function in with the corresponding preimage of one, we obtain a bijection between and the subsets of . In particular, each function in is the characteristic function of a subset of .

Suppose that is finite with elements. For every element of , a characteristic function in is either 0 or 1. There are therefore distinct characteristic functions . Hence, the number of distinct subsets of is given by .

- Formulae

The formula for counting combinations has special cases that are worth memorizing:

- (There is only one way to pick no thing and only one way to pick all things.)
- (there are n ways to pick one thing or to leave one thing out)
- (There are the same number of ways of picking of things as there are of leaving out of things)

## Permutations[edit]

In this section, we will discuss groups of unique objects where ordering is important.

**Permutation:** An arrangement of objects without repetition where order is important.

**Importance of Order:** We say that the order is important when sets and contain the exact same objects, but in a different order. In this case, we treat them differently. For example, , and are different.

**Example:** Find all 2-letter permutations of

**Solution:** Start with the letter . It can pair up with , , or , but NOT . Therefore, all the two letter permutation that start with are:

Similarly, for B as the starting letter,

Notice that since the order is important, and are NOT the same thing!

For C,

Finally, for D,

Permutations using all the objects: objects, arranged into group size of without repetition, and order being important. Example: Find all permutations of .

Permutations of some of the objects: objects, group size , order is important. Example: Find all 2-letter combinations using letters

**Distinguished permutation:** if a word has letters, of which are unique, let be the frequency of each of the letters: .

Consider the integer set . 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 . The number of possibilities for the second item is , namely all the integers in except the first element in the list. Similarly, the number of distinct possibilities for the -th item is . This pattern continues until all the elements in are listed. Summarizing, we find that the total number of permutations of is -factorial, .

- Example

We wish to compute the number of permutations of . Since the set S contains three elements, it has 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 . A good approximation for when n is large is given by Stirling's formula,

as . The notation signifies that the ratio approaches 1 as tends to infinity.

### -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