This section presents some common methods for counting the number of outcomes in a set. When there are a lot of outcomes in an experiment, it is convenient to have a method of determining how many outcomes there are in \(S\).

Multiplication rule:

Suppose that an experiment has two parts or phases. In the first part there are \(n_{1}\) outcomes and in the second part there are \(n_{2}\) outcomes. The composite experiment which consists of both parts of the experiment then has \(n_{1}\times n_{2}\) possible outcomes.

Example: Despite all my rage…

Let \(E_{1}\) denote the selection of a rat form a cage containing one female (F) rat and one male (M) rat. Let \(E_{2}\) denote the administering of either drug A, drug B, or a placebo to the selected rat.

  • How many possible outcomes are there?
    • 2*3=6
  • List the possible outcomes
    • Female/A,Female/B,Female/C, Male/A, Male/B, Male/C

Another way of illustrating the multiplication principle is with a tree diagram. The diagram shows that there are \(n_{1}\)=2 possibilities for the gender of the rat and that for each of these outcomes there are \(n_{2}=3\) possibilities for the drug.

The multiplication rule can be extended to more than two experiments.

You try it

  1. Each year starts on one of the seven days (Sunday through Saturday). Each year is either a leap year (i.e., it includes February 29) or not. How many different calendars are possible for a year?
  • The year could start on one of 7 days: \(n_{1}=7\)
  • The year could be a leap year or not: \(n_{2} = 2\)

Total possible calendars: \(7*2 = 14\)

  1. A chemical engineer wishes to observe the effects of temperature, pressure, and catalyst concentration on the yield resulting from a certain reaction. If she intends to include two different temperatures, three pressures, and two levels of catalyst, how many different runs must she make in order to observe each temperature-pressure catalyst combination exactly twice?

2 temps * 3 pressure * 2 catalysts * 2reps = 24 combinations

  1. A restaurant offers a choice of four appetizers, fourteen entrees, six desserts, and five beverages. How many different meals are possible if a diner intends to order only three items, one from each menu? That is, you can’t have two desserts and no entree.

Let \(A\) = Appetizer, \(E\) = Enree, \(D\) = dessert and \(B\) = beverage. Then meals could be made from the following combinations of groups are possible:

  • AED = 4 appetizers * 14 entrees * 6 desserts
  • AEB = 4 appetizers * 14 entrees * 5 beverages
  • ADB = 4 appetizers * 6 desserts * 5 beverages
  • EDB = 14 entrees * 6 desserts * 5 beverages
4*14*6 + 14*6*5 + 4*6*5 + 4*14*5
## [1] 1156

Permutations

  • An ordered arrangements of a countable set of objects is called a permutation.
  • The number of permutations of \(n\) distinct objects is \(n!\).
  • The ! is a function called a factorial and is defined as

\[ n! = n * (n-1) * (n-2) * \ldots * 1 \]

Example

The “ice cream club” is hosting a make-your-own sundae at which the following are provided:

  • Ice Cream flavors: Chocolate, Cookies-n-cream, Strawberry, Vanilla

  • Toppings: Caramel, Hot Fudge, Marshmallow, M&Ms, Nuts, Strawberries

  • How many different sundaes are possible using one flavor of ice cream and three different toppings?

  • Let \(E_{1}\): 1 flavor of ice cream: 4 choices

  • Let \(E_{2}\): 3 different toppings: 6 choices on the first pick, then 5 choices remain for the second pick, then 4 choices remain for the 3rd pick.

4*(6*4*3)
## [1] 288
  • How many sundaes are possible using one flavor of ice cream and from 0 to 6 toppings?

  • \(E_{1}\): 1 flavor of ice cream: 4 choices

  • \(E_{2}\): Different toppings - can happen in several ways. You can choose 6 OR 5 OR 4 OR 3 OR 2 OR 1 topping:

    • 6 different toppings = \(6!\) ways
    • 5 different toppings = \(6*5*4*3*2\)
    • 4 different toppings = \(6*5*4*3\)
    • 3 different toppings = \(6*5*4\)
    • 2 different toppings = \(6*5\)
    • 1 topping = \(6\)
    • 0 toppings = \(1\)
4*(factorial(6) + (6*5*4*3*2) + (6*5*4*3) + (6*5*4) + (6*5) + 6 + 1)
## [1] 7828

You try it

There are 9 presidential candidates at a debate. How many different ways can candidates be lined up?

factorial(9)
## [1] 362880

Combinations

If the order of objects is not important, then the number of ways of choosing \(k\) distinct objects from a set of \(n\) is given by

\[ \binom{n}{k}=\frac{n!}{k!\left(n-k\right)!}. \]

Handy r functions: factorial(x) and choose(n, k)

Example: \(\alpha\beta\zeta\)

The Alpha Beta Zeta sorority is trying to fill a pledge class of nine new members during fall rush. Among the twenty-five available candidates, fifteen have been judged marginally acceptable and ten highly desirable. How many ways can the pledge class be chosen to give a two-to-one ratio of highly desirable to marginally acceptable candidates?

  • 25 total candidates to choose 9 from
    • 15 candidates are marginal
    • 10 candidates are highly desired

If we want a 2:1 ratio of highly:marginal candidates, we want 6 highly desirable and 3 marginal candidates.

  • \(E_{1}\): Out of the 15 marginal candidates, choose 3 : \(\binom{15}{3}\)
  • \(E_{1}\): Out of the 10 highly desirable candidates, choose 6: \(\binom{10}{6}\)

\[ \binom{15}{3} * \binom{10}{6} \\ = \frac{15!}{3!12!} * \frac{10!}{6!4!} \\ = \frac{15*14*13*12!}{(3*2*1)*12!} * \frac{10*9*8*7*6!}{6!(4*3*2*1)} \\ = (5*7*13) * (10*3*7) \]

5*7*13*10*3*7
## [1] 95550
choose(15,3)*choose(10,6)
## [1] 95550

You try it

For each of these, write the R code used to calculate the answer and the answer itself.

  1. Among the 9 presidential candidates at a debate, 3 are republicans and 6 are democrats. How many different line ups are possible if the only ordering that matters is political party (not name)?

How many different ways can you line up 6 Democrats in 9 spots?

choose(9,6)
## [1] 84

OR

How many different ways can you line up 3 Republicans in 9 spots?

choose(9,3)
## [1] 84
  1. Nine students, five statistics majors and 4 computer science majors, interview for four summer internships sponsored by Google.
  1. In how many ways can Google choose a set of four interns?
choose(9,4)
## [1] 126
  1. In how many can Google choose 2 stat majors and 2 computer science majors?
choose(5,2)*choose(4,2)
## [1] 60
  1. How many sets of four can be picked such that not everyone in the set is the same major?

Find the way that groups of 4 can be picked such that EVERYONE is in the same major, and subtract that from the total # of ways to choose 4 interns.

choose(9,4) - (choose(5,4) + choose(4,4))
## [1] 120

Combinatorial Probability

In the previous section our concern focused on counting the number of ways a given operation, or sequence of operations could be performed. In this section we want to calculate the probability that a certain combination will occur. For instance, from the previous section we would be able to count the total number of ways a poker player could draw a straight. What if the poker player wanted to determine the probability of a straight. How could we set this up?

Example: Gender equality in promotions

Ten equally qualified marketing assistants are candidates for promotion to associate buyer; seven are men and three are women. If the company intends to promote four of the ten at random, what is the probability that exactly two of the four are women?

  • Promote 4 out of 10 people: \(\binom{10}{4}\)
  • 2 out of 3 women: \(\binom{3}{2}\)
  • 2 out of 7 men: \(\binom{7}{2}\)
total <- choose(10,4)
two_women <- choose(3,2)*choose(7,2)
(prob_two_women<-two_women/total)
## [1] 0.3

Example: Urns and chips

An urn contains twenty chips, numbered 1 through 20. Two are drawn simultaneously. What is the probability that the numbers on the two chips will differ by more than 2? Hint: Calculate the complement and subtract from one.

total<-choose(20,2)
1-(19/total+18/total)
## [1] 0.8052632

You try it:

  1. An apartment building has eight floors. If seven people get on the elevator on the first floor, what is the probability that they all want to get off on different floors? On the same floor?
  • Total possibilities for 7 people to get off on each of 7 floors = \(7*7*7*7*7*7*7 = 7^{7}\) options
  • 7 different floors: \(7!\) options
  • all same floor: 7 options
total <- 7^7
diff <- factorial(7)
same <- 7

P(different)

diff / total
## [1] 0.006119899

P(all same)

same/total
## [1] 8.49986e-06
  1. If four dice are rolled, what is the probability that each of the four numbers that appear will be different?
  • First die has 6 faces, 2nd die has 5 faces that are different from the 1st, 3rd die has 4 faces different from 1st and 2nd .. etc
  • total possible combinations of 6 faces on 4 dice: \(6*6*6*6\)
(6*5*4*3)/6^4
## [1] 0.2777778