You are on page 1of 43

2/11/2024 1

2/11/2024 2
Summary
 The Product Rule
 The Sum Rule
 The Subtraction Rule
 The Division Rule
 Tree Diagrams
 Permutations
 Combinations

2/11/2024 3
Basic Counting Principles: The Product
Rule
The Product Rule: A procedure can be broken down into a
sequence of two tasks. There are n1 ways to do the first task
and n2 ways to do the second task. Then there are n1∙n2
ways to do the procedure.

Example: How many bit strings of length seven are there?


Solution: Since each of the seven bits is either a 0 or a 1, the
answer is 27 = 128.

2/11/2024 4
The Product Rule
Example: How many different license plates can be made if
each plate contains a sequence of three uppercase English
letters followed by three digits?
Solution: By the product rule,
there are 26 ∙ 26 ∙ 26 ∙ 10 ∙ 10 ∙ 10 = 17,576,000 different
possible license plates.

2/11/2024 5
Product Rule in Terms of Sets
 If A1, A2, … , Am are finite sets, then the number of elements
in the Cartesian product of these sets is the product of the
number of elements of each set.
 The task of choosing an element in the Cartesian product
A1 × A2 × ∙∙∙ × Am is done by choosing an element in A1, an
element in A2 , …, and an element in Am.
 By the product rule, it follows that:
|A1 × A2 × ∙∙∙ × Am | = |A1| ∙ |A2| ∙ ∙∙∙ ∙ |Am|.

2/11/2024 6
Basic Counting Principles: The Sum Rule
The Sum Rule: If a task can be done either in one of n1 ways
or in one of n2, where none of the set of n1 ways is the same
as any of the n2 ways, then there are n1 + n2 ways to do the
task.

Example: The mathematics department must choose either


a student or a faculty member as a representative for a
university committee. How many choices are there for this
representative if there are 37 members of the mathematics
faculty and 83 mathematics majors and no one is both a
faculty member and a student.
Solution: By the sum rule it follows that there are 37 + 83 =
120 possible ways to pick a representative.

2/11/2024 7
The Sum Rule in terms of sets.
 The sum rule can be phrased in terms of sets.
|A ∪ B|= |A| + |B| as long as A and B are disjoint sets.
 Or more generally,
|A1 ∪ A2 ∪ ∙∙∙ ∪ Am | = |A1| + |A2| + ∙∙∙ + |Am|
when Ai ∩ Aj = ∅ for all i, j.
 The case where the sets have elements in common will be
discussed when we consider the subtraction rule and taken
up fully in next Chapter.

2/11/2024 8
Combining the Sum and Product Rule
Example: Suppose statement labels in a programming
language can be either a single letter or a letter followed by
a digit. Find the number of possible labels.
Solution: Use the product rule.
26 + 26 ∙ 10 = 286

2/11/2024 9
Counting Passwords
Example: Each user on a computer system has a password, which is six to
eight characters long, where each character is an uppercase letter or a
digit. Each password must contain at least one digit. How many possible
passwords are there?
Solution: Let P be the total number of passwords, and let P6, P7, and P8 be
the passwords of length 6, 7, and 8.
o By the sum rule P = P6 + P7 + P8.
o To find each of P6, P7, and P8 , we find the number of passwords of the
specified length composed of letters and digits and subtract the
number composed only of letters. We find that:
P6 = 366 − 266 = 1,867,866,560
P7 = 367 − 267 = 70,332,353,920
P8 = 368 − 268 = 2,612,282,842,880
2/11/2024 Consequently, P = P6 + P7 + P8 = 2,684,483,063,360. 10
Basic Counting Principles: Subtraction
Rule
Subtraction Rule: If a task can be done either in one of n1
ways or in one of n2 ways, then the total number of ways to
do the task is n1 + n2 minus the number of ways to do the
task that are common to the two different ways.
 Also known as, the principle of inclusion-exclusion:

2/11/2024 11
Counting Bit Strings
Example: How many bit strings of length eight either start
with a 1 bit or end with the two bits 00?
Solution: Use the subtraction rule.
 Number of bit strings of length eight
that start with a 1 bit: 27 = 128
 Number of bit strings of length eight
that end with bits 00: 26 = 64
 Number of bit strings of length eight
that start with a 1 bit and end with bits 00: 25 = 32
Hence, the number is 128 + 64 − 32 = 160.
2/11/2024 12
Basic Counting Principles: Division Rule
Division Rule: There are n/d ways to do a task if it can be done using a procedure that
can be carried out in n ways, and for every way w, exactly d of the n ways correspond
to way w.

Example: How many ways are there to seat four people around a circular table, where
two seatings are considered the same when each person has the same left and right
neighbor?
Solution: Number the seats around the table from 1 to 4 proceeding clockwise. There
are four ways to select the person for seat 1, 3 for seat 2, 2, for seat 3, and one way for
seat 4. Thus there are 4! = 24 ways to order the four people. But since two seatings are
the same when each person has the same left and right neighbor, for every choice for
seat 1, we get the same seating.
Therefore, by the division rule, there are 24/4 = 6 different seating arrangements.

2/11/2024 13
Basic Counting Principles: Division Rule
Examples:

2/11/2024 14
Tree Diagrams
 Tree Diagrams: We can solve many counting problems through the use
of tree diagrams, where a branch represents a possible choice and the
leaves represent possible outcomes.

Example: Suppose that “I Love Discrete Math” T-shirts come in five


different sizes: S,M,L,XL, and XXL. Each size comes in four colors (white,
red, green, and black), except XL, which comes only in red, green, and
black, and XXL, which comes only in green and black. What is the
minimum number of shirts that the campus book store needs to stock to
have one of each size and color available?
Solution: Draw the tree diagram.

The store must stock 17 T-shirts.


2/11/2024 15
Permutations
Definition: A permutation of a set of distinct objects is an
ordered arrangement of these objects. An ordered
arrangement of r elements of a set is called an r-permutation.

Example: Let S = {1, 2, 3}.


o The ordered arrangement 3,1,2 is a permutation of S.
o The ordered arrangement 3,2 is a 2-permutation of S.
 The number of r-permutations of a set with n elements is
denoted by P(n, r).
o The 2-permutations of S = {1, 2, 3} are 1,2; 1,3; 2,1; 2,3;
3,1; and 3,2. Hence, P(3, 2) = 6.
2/11/2024 16
A Formula for the Number of
Permutations
Theorem 1: If n is a positive integer and r is an integer with 1
≤ r ≤ n, then there are
P(n, r) = n(n − 1)(n − 2) ∙∙∙ (n − r + 1)
r-permutations of a set with n distinct elements.
 Note that P(n, 0) = 1, since there is only one way to order
zero elements.

Corollary 1: If n and r are integers with 1 ≤ r ≤ n, then

2/11/2024 17
Solving Counting Problems by Counting
Permutations
Example: How many ways are there to select a first-prize
winner, a second prize winner, and a third-prize winner
from 100 different people who have entered a contest?
Solution:
P(100, 3) = 100 ∙ 99 ∙ 98 = 970,200

2/11/2024 18
Solving Counting Problems by Counting
Permutations
Example: Suppose that a saleswoman has to visit eight
different cities. She must begin her trip in a specified city,
but she can visit the other seven cities in any order she
wishes. How many possible orders can the saleswoman use
when visiting these cities?
Solution: The first city is chosen, and the rest are ordered
arbitrarily. Hence the orders are:
7! = 7 ∙ 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 5040
If she wants to find the tour with the shortest path that
visits all the cities, she must consider 5040 paths!

2/11/2024 19
Solving Counting Problems by Counting
Permutations
Example: How many permutations of the letters
ABCDEFGH contain the string ABC ?
Solution: We solve this problem by counting the
permutations of six objects, ABC, D, E, F, G, and H.
6! = 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 720

2/11/2024 20
Combinations
Definition: An r-combination of elements of a set is an
unordered selection of r elements from the set. Thus, an r-
combination is simply a subset of the set with r elements.
 The number of r-combinations of a set with n distinct
elements is denoted by C(n, r). The notation

is also used and is called a binomial coefficient.

Example: Let S be the set {a, b, c, d}. Then {a, c, d} is a 3-


combination from S. It is the same as {d, c, a} since the
order listed does not matter.
 C(4, 2) = 6 because the 2-combinations of {a, b, c, d} are the
six subsets {a, b}, {a, c}, {a, d}, {b, c}, {b, d}, and {c, d}.
2/11/2024 21
Combinations
Theorem 2: The number of r-combinations of a set with n
elements, where n ≥ r ≥ 0, equals

2/11/2024 22
Combinations
Example: How many poker hands of five cards can be dealt
from a standard deck of 52 cards? Also, how many ways are
there to select 47 cards from a deck of 52 cards?
Solution: Since the order in which the cards are dealt does
not matter, the number of five card hands is:

 The different ways to select 47 cards from 52 is

2/11/2024 23
Combinations
Example: How many ways are there to select five players
from a 10-member tennis team to make a trip to a match at
another school.
Solution: By Theorem 2, the number of combinations is

Example: A group of 30 people have been trained as


astronauts to go on the first mission to Mars. How many
ways are there to select a crew of six people to go on this
mission?
Solution: By Theorem 2, the number of possible crews is

2/11/2024 24
2/11/2024 25
Summary
 Introduction to Discrete Probability
 Probabilities of Complements and Unions of Events
 Probabilistic Reasoning
 Assigning Probabilities
 Probabilities of Complements and Unions of Events
 Bernoulli Trials

2/11/2024 26
Introduction to Discrete Probability
 An experiment is a procedure that yields one of a given set of
possible outcomes.
 The sample space of the experiment is the set of possible
outcomes.
 An event is a subset of the sample space.

Consider the experiment of rolling one die, the sample space is


S1 = {1, 2, 3, 4, 5, 6}.
• E1 = {1}; Event (simple) of occurring 1
• E2 = {2, 4, 6}; Event (compound) of occurring even number

If we are interested only in whether the number is even or odd, the


sample space is simply
S2 = {even, odd}.
2/11/2024 27
Pierre-Simon Laplace
(1749-1827)

Introduction to Discrete Probability


Definition: If S is a finite sample space of equally likely outcomes,
and E is an event, that is, a subset of S, then the probability of E
is p(E) = |E|/|S|.
 For every event E, we have 0 ≤ p(E) ≤ 1. This follows directly
from the definition because 0 ≤ p(E) = |E|/|S| ≤ |S|/|S| ≤ 1,
since 0 ≤ |E| ≤ |S|.

Example: A coin is tossed twice. What is the probability that at


least 1 head occurs?
Solution: The sample space for this experiment is
S = {HH, HT, TH, TT}.
If E represents the event of at least 1 head occurring, then
E = {HH ,HT, TH} and
2/11/2024 P(E) = (1/4) + (1/4) + (1/4) = 3/4. 28
Applying Laplace’s Definition
Example: An urn contains 4 blue balls and 5 red balls. What
is the probability that a ball chosen from the urn is blue?
Solution: The probability that the ball is chosen is 4/9 since
there are nine possible outcomes, and four of these
produce a blue ball.

Example: What is the probability that when two dice are


rolled, the sum of the numbers on the two dice is 7?
Solution: By the product rule there are 62 = 36 possible
outcomes. Six of these sum to 7. Hence, the probability of
obtaining a 7 is 6/36 = 1/6.

2/11/2024 29
Applying Laplace’s Definition
Example: There are many lotteries that award prizes to
people who correctly choose a set of six numbers out of the
first n positive integers, where n is usually between 30 and
60. What is the probability that a person picks the correct
six numbers out of 40?
Solution: The number of ways to choose six numbers out of
40 is
C(40, 6) = 40!/(34!6!) = 3,838,380.
Hence, the probability of picking a winning combination is
1 / 3,838,380 ≈ 0.00000026.

2/11/2024 30
Applying Laplace’s Definition
Example: What is the probability that the numbers 11, 4, 17,
39, and 23 are drawn in that order from a bin with 50 balls
labeled with the numbers 1, 2, …, 50 if
a) The ball selected is not returned to the bin.
b) The ball selected is returned to the bin before the next
ball is selected.
Solution: Use the product rule in each case.
a) Sampling without replacement: The probability is
1/254,251,200 since there are 50 ∙ 49 ∙ 47 ∙ 46 ∙ 45 =
254,251,200 ways to choose the five balls.
b) Sampling with replacement: The probability is 1/505 =
1/312,500,000 since 505 = 312,500,000.
2/11/2024 31
The Probability of Complements and
Unions of Events
Theorem 1: Let E be an event in sample space S. The
probability of the event
E  S  E,
the complementary event of E, is given by
p ( E )  1  p ( E ).

Theorem 2: Let E1 and E2 be events in the sample space S.


Then
p ( E1  E2 )  p ( E1 )  p ( E2 )  p ( E1  E2 )

2/11/2024 32
The Probability of Complements and
Unions of Events
Example: A sequence of 10 bits is chosen randomly. What is
the probability that at least one of these bits is 0?
Solution: Let E be the event that at least one of the 10 bits is
0. Then is the event that all of the bits are 1s. The size of
the sample space S is 210. Hence,

2/11/2024 33
The Probability of Complements and
Unions of Events
Example: What is the probability that a positive integer
selected at random from the set of positive integers not
exceeding 100 is divisible by either 2 or 5?
Solution: Let E1 be the event that the integer is divisible by 2
and E2 be the event that it is divisible 5? Then the event
that the integer is divisible by 2 or 5 is E1  E2 and E1  E2 is
the event that it is divisible by 2 and 5.
It follows that:
p(E1  E2) = p(E1) + p(E2) – p(E1  E2)
= 50/100 + 20/100 − 10/100 = 3/5.

2/11/2024 34
Assigning Probabilities
Laplace’s definition assumes that all outcomes are equally likely.
Now we introduce a more general definition of probabilities that
avoids this restriction.
 Let S be a sample space of an experiment with a finite number of
outcomes. We assign a probability p(s) to each outcome s, so
that:
i. 0 ≤ p(s) ≤ 1 for each s S
ii.

 The function p from the set of all outcomes of the sample space S
is called a probability distribution.

2/11/2024 35
Assigning Probabilities
Example: What probabilities should we assign to the
outcomes H (heads) and T (tails) when a fair coin is
flipped? What probabilities should be assigned to these
outcomes when the coin is biased so that heads comes up
twice as often as tails?
Solution: For a fair coin, we have p(H) = p(T) = 1/2.
For a biased coin, we have p(H) = 2p(T).
Because p(H) + p(T) = 1, it follows that
2p(T) + p(T) = 3p(T) = 1.
Hence, p(T) = 1/3 and p(H) = 2/3.

2/11/2024 36
Uniform Distribution
Definition: Suppose that S is a set with n elements. The
uniform distribution assigns the probability 1/n to each
element of S. (Note that we could have used Laplace’s
definition here.)

Example: Consider again the coin flipping example, but with


a fair coin. Now p(H) = p(T) = 1/2.

2/11/2024 37
Probability of an Event
Definition: The probability of the event E is the sum of the
probabilities of the outcomes in E.

 Note that now no assumption is being made about the


distribution.

2/11/2024 38
Example
Example: Suppose that a die is biased so that 3 appears twice
as often as each other number, but that the other five
outcomes are equally likely. What is the probability that an
odd number appears when we roll this die?
Solution: We want the probability of the event E = {1, 3, 5}.
We have p(3) = 2/7 and
p(1) = p(2) = p(4) = p(5) = p(6) = 1/7.
Hence,
p(E) = p(1) + p(3) + p(5) = 1/7 + 2/7 + 1/7 = 4/7.

2/11/2024 39
Probabilities of Complements and
Unions of Events
 Complements: still holds. Since each
outcome is in either E or E , but not both,

 Unions:
also still holds under the new definition.

Theorem: If E1, E2, … is a sequence of pairwise disjoint


events in a sample space S, then

2/11/2024 40
James Bernoulli
Bernoulli Trials (1854 – 1705)

Definition: Suppose an experiment can have only two


possible outcomes, e.g., the flipping of a coin or the
random generation of a bit.
o Each performance of the experiment is called a Bernoulli
trial.
o One outcome is called a success and the other a failure.
o If p is the probability of success and q the probability of
failure, then p + q = 1.
 Many problems involve determining the probability of k
successes when an experiment consists of n mutually
independent Bernoulli trials.
2/11/2024 41
Probability of k Successes in n
Independent Bernoulli Trials
Theorem 2: The probability of exactly k successes in n
independent Bernoulli trials, with probability of success p
and probability of failure q = 1 − p, is
C(n, k) pkqn−k.
 We denote by b(k: n, p) the probability of k successes in n
independent Bernoulli trials with p the probability of
success. Viewed as a function of k, b(k: n, p) is the binomial
distribution. By Theorem 2,
b(k: n, p) = C(n, k) pkqn−k.

2/11/2024 42
Bernoulli Trials
Example: A coin is biased so that the probability of heads is
2/3. What is the probability that exactly four heads occur
when the coin is flipped seven times?
Solution: There are 27 = 128 possible outcomes. The
number of ways four of the seven flips can be heads is C(7,
4). The probability of each of the outcomes is (2/3)4(1/3)3
since the seven flips are independent. Hence, the
probability that exactly four heads occur is
C(7,4) (2/3)4 (1/3)3 = (35 ∙ 16)/27 = 560/2187.

2/11/2024 43

You might also like