Math 1060 - Lecture 2
Math 1060 - Lecture 2
Counting
The Rules of Sum and Product
The Rule of Sum: If a first task can be performed in m ways, while a second task can be performed
in n ways, and the two tasks cannot be performed simultaneously, then performing either task
can be accomplished in any one of m + n ways.
The Rule of Product: If a procedure can be broken down into first and second stages, and if there
are m possible outcomes for the first stage and if, for each of these outcomes, there are n possible
outcomes for the second stage, then the total procedure can be carried out, in the designated
order, in mn ways.
Example 1. Consider binary strings of length 16.
a) How many strings start with 1101 and end with 01?
b) How many strings start with 1101 or end with 01?
Example 2. A collection of four routers is to be connected in a point‐to‐point subnet. Between
each pair of routers, the designers may put a high‐speed line, a medium‐speed line, a low‐
speed line, or no line. If it takes 100 ms of computer time to generate and inspect each
topology, how long will it take to inspect all of them?
Page | 21
Example 3.
A hat contains the numbers 1, 2 and 3 on 3 slips of paper. A number is drawn at random,
replaced and another one is drawn. How many ordered samples are possible?
Permutations
Example 1. Among 10 different treatments, four are to be chosen and given to the patient (in a
sequence). How many different therapies are possible? How many different therapies are
possible if all 10 treatments are given to the patient?
Given a set of n distinct objects, a permutation is an ordered arrangement of these objects.
For any integer n, n 1, the number of permutations of all n elements of the set is equal to n!
If we order only some (say r n ) elements of a set then we say we have an r‐permutation. The
number of r‐permutations of a set of n elements is denoted P(n, r).The number of r‐
permutations of a set with n distinct elements is denoted by P(n, r) and is equal to
n!
P(n, r ) n (n 1) (n 2) (n r 1) .
(n r )!
*Note: for r=n, (n‐r)!=(n‐n)!=0!=1 by definition (not zero)
Page | 22
Example 2.
a. What is the number of permutations of the letters of the word MEDICAL?
b. If only four letters are used, how many permutations (no repetition of letters) of size four
are possible?
c. If repetitions of letters are allowed, what is the number of possible 12‐letter sequences?
Combinations:
Given a set of n distinct objects, a combination (or simple choice) is a selection of r objects from
the set of n available objects. In selecting objects, order does not matter.
For any integer n, n 1, the number of r‐ combinations (choose r from n) is given by:
!
𝐶 𝑛, 𝑟
! !
When dealing with any counting problem, we should ask ourselves about the importance of
order in the problem. When order is relevant, we think in terms of permutations,
arrangements, and the rule of product. When order is not relevant, combinations could play a
key role in solving the problem.
Example 3. Suppose that three ADAC students, among the 25 available, are to be selected to be
interviewed for a certain job. In how many ways can this selection be made?
Page | 23
Example 3 (continued). Suppose that two students, Julia and Hayley do not get along and the
two of them cannot be selected together. In how many ways the selection can be made?
Example 4: A council of size 14 is to be selected from10 women and 10 men. How many
different councils can be selected if:
There are no restrictions?
There must be equal number of women and men?
There must be either 4 or 5 men?
Example 5.
Consider passwords of length 12 made with upper case letters A,B, …, Z
What is the total number of passwords?
How many have all letters distinct?
How many passwords have at least one letter repeated?
Page | 24
Probability
Fundamental Definitions
Experiment: Any process that allows researchers to obtain observations
Event: Any collection of results or outcomes of an experiment.
Sample Space: Consists of all outcomes that cannot be broken down any further
Probability: A numeric measure that based on our knowledge of the uncertain matter at
hand, quantifies the likelihood of an event occurring.
P denotes a probability. A, B and C denote specific events. P(A) denotes the probability of
event A occurring.
If the likelihood of the outcomes is not known then we can use the law of large numbers to
find empirical probabilities. It states that if we repeat the experiment n times (where n is a
very large number), then:
number of outcomes in A
P A
n
Classical Approach to Probability
Assume that a given experiment has n different simple events, each of which has an equal
chance of occurring. If event A can occur in s of these n ways, then:
P A
number of ways A can occur s
number of different simple events n
Example: Consider the random experiment of rolling a 6‐sided die twice. Let (3,2) denote the
outcome of getting a 3 on the first roll and a 2 on the second roll, etc. Then the sample space,
denoted S, is the set:
(1,1) (1, 2) (1,3) (1, 4) (1,5) (1, 6)
(2,1) (2, 2) (2, 3) (2, 4) (2,5) (2, 6)
(3,1) (3, 2) (3, 3) (3, 4) (3,5) (3, 6)
S
(4,1) (4, 2) (4, 3) (4, 4) (4,5) (4, 6)
(5,1) (5, 2) (5, 3) (5, 4) (5,5) (5, 6)
(6,1) (6, 2) (6,3) (6, 4) (6,5) (6, 6)
Page | 25
There are 36 possible outcomes in all.
Example: For the above example, let B the event that the rolls add up to 4. Then the probability
that the two rolls add up to 4 is P B 3 .
36
Example: Find the probability that a couple with 3 children will have exactly 2 boys. Assume that
boys and girls are equally likely and that the gender of any child is not influenced by the gender
of any other child.
Relationship Between Events
The relationships between any events A and B are described by the logical operations of and, or
and not.
“A and B”, written as 𝐴 ∩ 𝐵, is defined as the set of outcomes that belong to both A and
B simultaneously.
“A or B” written as 𝐴 ∪ 𝐵 is defined as the set of outcomes that belong to either A or B or
both.
“not A”, written as 𝐴 , 𝐴 , 𝑜𝑟 𝐴̅ is defined as the set of outcomes that do not belong to A.
“A but not B”, written as A‐B is the set of outcomes that are in A but not in the overlap
region between a and B.
The relationships can be illustrated with Venn diagrams.
Page | 26
A is shaded “not A” is shaded “A or B” is “A and B” is “A but not B” is
shaded shaded shaded
If “A and B” is empty then A and B have no outcomes in common. They are said to be disjoint or
mutually exclusive events. Then the Venn diagram looks like this:
A and B are disjoint so “A and
B” contains no events
The Addition Rule for the Probability of the Union of Events
Recall that 𝐴 ∪ 𝐵 is the set of outcomes that belong to either event A or event B or both. Its
probability is:
P(𝐴 ∪ 𝐵) = P(A) + P(B) ‐ P(𝐴 ∩ 𝐵)
This is called the addition rule. If A and B are mutually exclusive (disjoint) events then this
simplifies to:
P(𝐴 ∪ 𝐵) = P(A) + P(B).
In the first form P( Aand B ) is subtracted to avoid counting events common to A and B twice.
In the special case that B is A's complement, (ie. B = not A), the rule gives:
P(A) + P(not A) = 1.
Note: “not A” is denoted by either 𝑨′or 𝑨𝒄 or 𝑨
Page | 27
Example: Again suppose that a die is rolled twice. Let
A the event of getting same number on both rolls,
B the event that the rolls add up to 4, and
C the event that the rolls add up to 2.
First list the outcomes belonging to A, B, and C. Then list the outcomes belonging to
A and B,
A or B,
B and C.
Find:
a.) 𝑃 𝐵 , the probability that the rolls do not add up to 4
b.) P(𝐴 ∪ 𝐵 , the probability of getting the same number on both rolls or that the rolls add
to 4
c.) 𝑃 𝐴 ∩ 𝐵 , the probability that the rolls add up to 4 or that the rolls add up to 2
d.) 𝑃 𝐴 𝐵 , the probability that same number shows on both rolls, but do not add up to 4
Page | 28
Example: Manufactured bolts in a certain factory can be defective in two different ways; they
can have the incorrect length or incorrect diameter. We know from past tests that the
probability of a bolt being fine is 0.95 and 2% of the bolts are only incorrect in diameter and
0.5% is the proportion of bolts that are the wrong length and the wrong diameter. What is the
probability of a bolt being either the wrong length or the wrong diameter?
Example: Samples of size 3 are selected from the set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. We choose these
samples without replacement; that is, once a number is chosen, it is removed from the set and
cannot be selected again. Examples of some possible samples are {1, 4, 7}, {2, 4, 9}, and {6, 7, 10}.
The order in which samples items are drawn is irrelevant. What is a probability that the sample
contains 1 or 2 (inclusive or)?
Example: Referring to the previous example, suppose we know that a sample contains the
number 5. What then is the probability that the sample also contains the number 4?
Page | 29
The Multiplication Rule for the Probability of the Intersection of Events
Notation: The conditional probability that event B will occur, given that event A has already
occurred is denoted by; P(B | A). It reads as: Probability of B given that A has happened.
Definition: Two events A and B are independent if the occurrence of one does not affect the
probability of the occurrence of the other. In equation form, B is independent of A if P(B | A) =
P(B). If two events are not independent, then we say that they are dependent.
Recall that A and B is the set of outcomes that belong to both event A and event B
simultaneously. Its probability is:
P A and B P A P B | A
This form assumes that A occurs first. If B occurs first then P A and B P B P A | B . This is
called the multiplication rule. If A and B are independent events then this simplifies to:
P A and B P A P B .
The multiplication rule can be manipulated to give the following definition for the condition
probability:
P B and A
P B | A
P A
These examples illustrate the multiplication rule.
Example: A test consists of one true or false question and one multiple choice question with 4
possible answers. If a student gives random responses to both questions, what is the probability
that they will answer both questions correctly?
Page | 30
Example: Pick 2 children at random from a group of 10 boys and 10 girls. What is the probability
of picking 2 girls?
Example: Given that 0.4% of women, 8% of men have congenital color blindness. What is the
probability of a randomly chosen person is a color blind man?
Example: In a certain college town, some of the inhabitants attend college and other inhabitants
own computers as shown in the following contingency table:
attend college don't attend total
college
own a computer 800 3200 4000
don't own 200 800 1000
computer
total 1000 4000 5000
Suppose we select one inhabitant at random. Let A the event that the inhabitant attends
college and C the event that the inhabitant owns a computer. Find P(A and C), the probability
that the randomly selected inhabitant attends college and owns a computer.
Find P(C) and P(C|A). What do you conclude?
Page | 31
Bayes’ Theorem
Combining the two version of the multiplication equations above, P(B|A)⋅P(A)=P(A|B)⋅P(B), and
dividing both sides by P(A) we obtain so called Bayes’ theorem:
P( A | B )ꞏP( B)
P( B | A)
P( A)
If P(A) is not known to us, we need to find it by using this formula:
𝑃 𝐴 𝑃 𝐴|𝐵 . 𝑃 𝐵 𝑃 𝐴|𝐵 𝑃 𝐵
Making two‐way tables is an effective way of solving some Bayes Theorem related problems.
Example : Suppose a drug test gives 99% true positive results for drug users and 98% true
negative results for non‐drug users. Suppose 0.5% of people are users of the drug. If a randomly
selected individual tests positive, what is the probability that he is a user?
Page | 32