counting and probability

64
Counting and probability

Upload: casimir-lel

Post on 31-Dec-2015

61 views

Category:

Documents


0 download

DESCRIPTION

Counting and probability. What do you mean by counting? How do you count things in daily life? Counting the European way or the English speaking way? 8 days a week (not the Beatles song)?. 1.1 Linear Series Rule. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Counting and probability

Counting and probability

Page 2: Counting and probability

•What do you mean by counting?•How do you count things in daily life?•Counting the European way or the English speaking way?•8 days a week (not the Beatles song)?

Page 3: Counting and probability

1.1 Linear Series Rule.

If m and n are integers such that m n, then there are n-m+1 integers from m to n inclusive. 1.1 Linear Series Rule.

Example 1: How many integers are there in the sequence 10, 11, 12, …, 19, 20?

Example 2: How many integers are there in the sequence -8,-7,-6,…-1,0,1,2,…4, 5?

Example 3: How many integers are there in 0 to 1000 inclusive, that are divisible by 3.

Page 4: Counting and probability

1.1 Linear Series Rule.

If m and n are integers such that m n, then there are n-m+1 integers from m to n inclusive. 1.1 Linear Series Rule.

Example 1: How many integers are there in the sequence 10, 11, 12, …, 19, 20?

Ans: 20 – 10 + 1 = 11

Example 2: How many integers are there in the sequence -8,-7,-6,…-1,0,1,2,…4, 5?

Ans: 5 – (–8) + 1 = 14

Example 3: How many integers are there in 0 to 1000 inclusive, that are divisible by 3.

The integers are 0,3,6,9,…,996,999 , which are in the form 3k, where k = 0,1,2,…,333.

Hence there are 333-0+1 = 334 integers from 0 to 1000 which are divisible by 3.

Page 5: Counting and probability

What is Probability?

A coin has a 50% chance of landing heads. What does that mean? The coin will land heads 50% of the time?

not really. The coin will land heads approximately 50% of the time?

Then the probability is approximately 50%, not exactly 50%.

It means that the fraction of the time that the coin lands heads will get arbitrarily close to 50% as the number of coin tosses increases without bound.

Page 6: Counting and probability

The Sample Space•An experiment is a procedure that leads to an outcome.

Toss a coin.• We observe a characteristic of the outcome.

Which side landed up?• The sample space is the set of all possible observations/ outcomes.

Sample space = {H, T}•An event is a collection of possible observations, i.e., a subset of the sample space.

E(H) = 1

A sample space is the set of all possible outcomes of a random process or experiment. An event is a subset of a sample space.

Page 7: Counting and probability

Some points to ponder.•The processes are random, i.e. some set of outcomes is sure to occur but it is impossible to predict with certainty which one.•We will consider only finite sample spaces.

•The probability of an event is the sum of the probabilities of its individual members.• If the members of the sample space are equally likely, then P(E) = |E|/|S|.•If the n members of the sample space are equally likely, then the probability of each member is 1/n. •Examples Toss a coin, P(H) = 1/2. Roll a die, P(3) = 1/6.

Page 8: Counting and probability

Possibility Trees and the Multiplication Rule

Page 9: Counting and probability

•Often, an experiment may be viewed as a sequence of simple procedures, or sub-experiments.• An outcome of the experiment will be a sequence of outcomes of the sub-experiments. •To analyze the experiment, we should first analyze the sub-experiments.

•Draw three cards, with replacement, from a shuffled deck 1st sub-experiment:

Draw the 1st card. 2nd sub-experiment:

Draw the 2nd card. 3rd sub-experiment:

Draw the 3rd card. •What is the sample space? Are the outcomes equally likely? What if we drew without replacement?

Page 10: Counting and probability

•A possibility tree Starts at a root. Has one level for each sub-experiment. At each level, shows a set of branches for all the possibilities (sample space) of that sub-experiment.

•If sub-experiment #1 has m possible outcomes

• and sub-experiment #2 has n possible outcomes (no matter how

sub-experiment #1 turned out),• then

the two sub-experiments in sequence have mn possible outcomes.

Multiplication Rule

If an operation consists of a sequence of steps/events E1, E2 … Ek and if each Ei can be performed in ni ways regardless of how the previous steps E1, … Ei-1 were performed (i.e. independent), then the entire operation can be performed in n1´n2´…´nk ways.

Page 11: Counting and probability

Examples Toss 5 coins: 2 2 2 2 2 = 32 possibilities Roll 3 dice: 6 6 6 = 216 possibilities Draw 5 cards (without replacement): 52 51 50 49 48 = 311,875,200

possibilities

Example 1:What is the maximum number of possible 3-letter English words with the pattern consonant-vowel-consonant?

Example 2: How many odd numbers greater than 3000 can be formed by using each of the digits 1, 2, 3, and 4 once?Example 3: A car license plate has 3 letters of alphabet followed by 4 single digit

numbers. How many different car licenses can be issued (a) if repetitions of alphabets/numbers in the license plate is allowed; (b) if repetitions are not allowed?

Example 4: (Limitations of the Multiplication Rule)

Two teams A and B are to play each other repeatedly until one wins two games in a row, or until a total of 3 games. How many ways can a tournament be played?

Page 12: Counting and probability

Why do the rules of multiplication not apply here?

A wins B wins

A wins B wins

A wins B wins

A wins B wins

A wins B wins

Page 13: Counting and probability

Example 5: Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen?

Selecting three officers can be broken down to the following tasks:

Step 1: Select the president : 3 ways.

Step 2: Select the treasurer : 3 ways.

Step 3: Select the secretary : 2 ways.

Total number of performing the task = 3 .3 .2 ways

Page 14: Counting and probability

Example 5: Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen?

Goal Re-ordering is a possible way to by-pass dependency of tasks

1. Select the president: 3 ways

2. Select the treasurer: number of ways DEPENDENT on the outcome of step 1!!!

3. Select the secretary: number of ways DEPENDENT on the outcome of step 2, which is in turn, DEPENDENT on step 1.

C

D

A

A

B

A

B

D

C

D

C

D

D

C

C

start

B

C

D

Page 15: Counting and probability

(Goal Re-ordering is a possible way to by-pass dependency of tasks)

Step 1: Select the secretary : 2 ways (C or D).

Step 2: Select the president : 2 ways regardless of the choice taken in step 1 (person B with the remaining person from step 1)

Step 3: Select the treasurer : 2 ways. (person A with the person remaining from step 2)

Total number of performing the task = 2 * 2 * 2 ways

C

D

A

A

B

A

B

D

C

D

C

D

D

C

C

start

B

C

D

Page 16: Counting and probability

Each step is independent of the choices of previous step.

The number of ways of each step is independent of the choices of the previous step

Page 17: Counting and probability

Permutations

Page 18: Counting and probability

• A permutation of the elements of a set is an ordering of those elements.• Distinct orderings are distinct permutations. • The permutations of {a, b, c} are abc, acb, bac, bca, cab, and cba.

1. a permutation of a set S of n distinct objects is an ordered list of these objects

2. an r-permutation is an ordered list of r elements of S S={1,2,3}, all permutations={(1,2,3),(2,1,3),(1,3,2),(2,3,1),(3,1,2),(3,2,1)} all 2-permutations={(1,2),(2,1),(1,3),(3,1),(2,3),(3,2)}

3. the number of r-permutations of a set S with n elements is written as P(n,r).

4. If n and r are integers such that , then P(n,r) = n*(n-1)*(n-2)*...*(n-r+1) = n!/(n-r)!

5. P(n,n) = n! / (n-n)! = n!

nr 1

Page 19: Counting and probability

• 6. CIRCULAR PERMUTATIONS– The number of ways of permuting r objects from a set of n

objects in a circle (in which two arrangements are the same when one is a rotation of the other) is P(n,r) / r.

• 1. How many different ways can a salesman visit 8 cities? • 2. How many different ways can 10 horses in a race win, place and

show (come in first, second, third)?

Page 20: Counting and probability

Addition and Difference rule

Theorem: Let {A1, …, An} be a partition of a set A.

Then |A| = |A1| + … + |An|.

Corollary: Let {A1, …, An} be a collection of pair wise disjoint finite sets.

Then |A1 … An| = |A1| + … + |An|.

Page 21: Counting and probability

Addition Rule:

If a finite set A = A1 A2 An where all the Ai’s are mutually disjoint, then |A| = |A1| + |A2| + + |An|

Difference Rule:

If A is a finite set and BA, then |A – B| = |A| – |B|

Page 22: Counting and probability

Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible?

Set of all code words of length 3

Set of all code words of length 1

Set of all code words of length 2

Set of all code words of length 3

• By addition rule: |Set of all code words of length 3 | = | Set of all code words of length 1 | + | Set of all code words of length 2 |

+ | Set of all code words of length 3 |

Page 23: Counting and probability

Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible?

Set of all code words of length 3

Set of all code words of length 1

Set of all code words of length 2

Set of all code words of length 3

• Number of code words of length 1 = 26• Number of code words of length 2 = 262 (Multiplication Rule)• Number of code words of length 3 = 263 (Multiplication Rule)• Total number of code words = 26 + 262 + 263 (Addition Rule)

Page 24: Counting and probability

Basic Rules: Addition/Difference Rule

Example 2: There are 15 different computer science books, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject?

• By addition rule: |Set of selections of 2 books|= | Set of selection of 1 book from CS and 1 book from Math |+ | Set of selection of 1 book from CS and 1 book from Chem |+ | Set of selection of 1 book from Math and 1 book from Chem |

Set of selections of 2 books

1 book from CS and 1 book

Math

1 book from CS and 1 book from Chemistry

1 book from Math and 1 book from Chemistry

Page 25: Counting and probability

Example 2: There are 15 different computer science books, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject?

Set of selections of 2 books

1 book from CS and 1 book Math

1 book from CS and 1 book from Chemistry

1 book from Math and 1 book from Chemistry

15 12

(M.R.)

15 10

(M.R.)

12 10

(M.R.)+ +

Page 26: Counting and probability

Basic Rules: Addition/Difference Rule

Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated?

Answer:

Different arrangements of 8 people in a row = 8! (by multiplicaton rule)

How?

Step 1: Sit the 1st person: 8 ways

Step 2: Sit the 2nd person: 7 ways regardless of outcome of step 1.

Step 3: Sit the 3rd person: 6 ways regardless of outcome of step 1-2.

Different arrangements of

8 people in a row where the 2

enemies sit next to each other

Different arrangements of 8 people in a row where the 2 enemies sit apart

Page 27: Counting and probability

Basic Rules: Addition/Difference Rule

Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated?

Answer:Different arrangements of 8 people in a row = 8!

Different arrangements of

8 people in a row where the 2

enemies sit next to each other

Different arrangements of 8 people in a row where the 2 enemies sit apart

= 2*7 ! (by multiplicaton rule)

How?

Step 1: Sit the 2 enemies together: 2*7 ways

Step 2-7: Sit the remaining 6 people: 6*5*4*3*2*1

Step 1: Combine the 2 enemies as 1 person and take it as an arrangement of 7 people to 7 chairs, (7!).

Step 2: Different ways of arranging the 2 enemies to sit side-by-side: 2 ways.

OR… Another way of looking at it:

Page 28: Counting and probability

Basic Rules: Addition/Difference Rule

Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated?

Answer:

Different arrangements of 8 people in a row = 8!

Different arrangements of

8 people in a row where the 2

enemies sit next to each other

Different arrangements of 8 people in a row where the 2 enemies sit apart

= 2*7! (by multiplicaton rule)

Answer = 8! – 2*7! (Difference Rule)

Page 29: Counting and probability

Basic Rules: Addition/Difference Rule

Example 4: How many integers are there in 1000 to 9999 that contain at least a digit 5.

Answer= (Number of integers in 1000 to 9999) –

(Number of integers in 1000 to 9999 that do not contain a digit 5)(Difference Rule)

= (9999 – 1000 + 1) – 8.93 (Linear Series Rule) (Multiplication Rule)

= 3168

If S is a finite sample space and A is an event in S, then

Page 298 example 6.3.3

)(1)( APAP c

Page 30: Counting and probability

Basic Rules: Addition/Difference Rule

Example 5: How many 3 digit numbers have at least one digit repeated?

Answer= Number of 3 digit numbers – Number of 3 digit numbers which have NO digit repeated (Difference Rule)

(9 *10 *10) Multiplication Rule:Step 1: Choose hundredths digit (must exclude

leading ‘0’, therefore only 9 ways)Step 2: Choose tenths digitStep 3: Choose units digit

(9 *9 *8) Multiplication Rule:Step 1: Choose hundreths digit (must exlude leading

‘0’)Step 2: Choose tenths digit (10 ways, excluding

the digit in step 1. Therefore 9 ways)Step 3: Choose units digit

Page 31: Counting and probability

Basic Rules: Inclusion-Exclusion Rule

Page 32: Counting and probability

1.4Inclusion-Exclusion Rule:

• (For 2 sets) Given any sets A and B,

|A B| = |A| + |B| – |A B|

• (For 3 sets) Given any sets A, B and C,

|A B C | = |A| + |B| + |C| – |A B| – |A C| – |B C| + |A B C|

• (For n sets) Given any sets A1 … An,

| A1 … An | =

| Ai |

– | Ai Aj |

+ | Ai Aj Ak |

– …The pattern is to add “one at a time”, subtract “two at a time”, and add “three at

a time” and so on.

},...,1{ ni

distinct ji, {1..n} ji,

distinctk j,i, {1..n} k j,i,

Page 33: Counting and probability

Basic Rules: Inclusion-Exclusion Rule

Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5?

Answer:|{Integers of multiples of 3 or 5}|

= |{Integers of multiples of 3}|+ |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule)

All integers fom 1 to 1000

Multiples of 5

Multiples of 3

Page 34: Counting and probability

Basic Rules: Inclusion-Exclusion Rule

Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5?

Answer:|{Integers of multiples of 3 or 5}|

= |{Integers of multiples of 3}|+ |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule)

|{Integers of multiples of 3}| = |{3k | where k = 1,2,…333}| = 333|{Integers of multiples of 5}| = |{5k | where k = 1,2,…200}| = 200|{Integers of multiples of 3 and 5}| = |{15k | where k = 1,2,…66}| = 66

Ans = 333 + 200 – 66= 467

Page 35: Counting and probability

Basic Rules: Inclusion-Exclusion Rule

Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5?

Question: How many are neither multiples of 3 nor 5?Answer: {Int from 1..1000} -{Int from 1..1000 with are multiples of 3 or 5}

Ans = 1000-467 (By difference rule)= 533

1000 467

How many primes are there between 1 and 100? The non-primes must be multiples of 2, 3, 5, or 7, since the square root of 100 is 10.

Page 36: Counting and probability

Counting subsets of a Set:Combinations

Page 37: Counting and probability

• Definition: – An r-combination of a set of n elements is a subset of r elements taken

from the set of n elements ( ).• Notation:

– The number of r-permutations of a set of n elements is denoted as C(n,r), also as and

• Note: A combination is an unordered selection: you are selecting a ‘set’, and ordering is not important in sets.

n r

rnC

r

n

Page 38: Counting and probability

Theorem: The number of r-combinations of a set of n elements is C(n, r) = n!/[r!(n – r)!].

Corollary: For all n 0 and 0 r n, P(n, r) = r! C(n, r).

Calculator toolsExample 1:

You are to select five members from a group of twelve to form a team.(a) How many distinct five-person teams can be selected?(b) If two of them insist on working together as a pair, such that any team must either contain both of neither. How many five person teams can be formed?Answer:

(a) C(12,5)All 5-person teams satisfying the ‘2-friends’

constraint.

Those teams which

involve the 2

‘friends’

Those teams which do not involve the 2 ‘friends’C(10,3) C(10,5)

Page 39: Counting and probability

1’st version using addition rule

Those teams which

contain A but not B

All 5-person teams that do not contain the two enemies, say A and B

Those teams which

contain B but not A

Those teams

which do not contain

A nor B

Step 1: select the A: 1 way

Step 2: select the remaining people except B: C(10,4)

C(10,4) C(10,4) C(10,5)+ +

Example 2 You are to select five members from a group of twelve to form a team. If two of them insist on working apart,how many five person teams can be formed?

Page 40: Counting and probability

Example 2 You are to select five members from a group of twelve to form a team. If two of them insist on working apart,how many five person teams can be formed?

All 5-person teams

Those teams with

the two enemies together

Those teams with the two enemies apart

C(12,5)

Ans: C(12,5) – C(10,3)Step 1: select the two enemies: 1 way

Step 2: select the remaining 3 people: C(10,3)

C(10,3)

2’nd version

Page 41: Counting and probability

Example : A group of twelve consists of five men and seven women.

(a) How many five-person teams can be chosen that consists of three men and two women?(b) How many five-person teams contain at least one man?(c) How many five-person teams contain at most one man?

(a) Answer:Step 1: choose the men: C(5,3) waysStep 2: choose the women: C(7,2) ways (regardless of the choices made in step 1)Multiplication rule: C(5,3) x C(7,2)

(b) Answer:Number of 5-person teams that contain at least one man= Number of 5-person teams– Number of 5-person teams that do not contain any men (all women).

(DIFFERENCE RULE)= C(12,5) – C(7,5)

Page 42: Counting and probability

(c) Answer:Number of 5-person teams that contain at most one man= Number of 5-person teams that contain no men+ Number of 5-person teams that contain 1 man

(BY ADDITION RULE)

= (C(5,0) x C(7,5)) Step 1: Choose 0 men from 5 menStep 1: Choose 5 women from 7 women

+ (C(5,1) x C(7,4)) Step 1: Choose 1 man from 5 menStep 2: choose 4 women from 7 women

Example 4: 10 people are to sit around two round tables. The first table has 6 chairs, the second

table has 4 chairs.(a) How many ways can this be done?(b) How many ways can this be done if two of them need to sit together?

Page 43: Counting and probability

(a) Answer (version#1):Step 1: Choose 6 people to sit on the first table

C(10,6)Step 2: Arrange the 6 people on the first table

5! (Circular Permutation)Step 3: Arrange the remaining 4 on the second table.

3! (Circular Permutation)(BY MULTIPLICATION RULE)

= C(10,6) x 5! x 3!= 10!/24

(a) Answer (version#2):Step 1: Permute 6 people from 10 circularly around the first table

P(10,6)/6Step 2: Arrange the remaining 4 on the second table.

3! (Circular Permutation)(BY MULTIPLICATION RULE)

= P(10,6)/6 x 3!= 10!/24

Page 44: Counting and probability

(b) Answer (version#1):BY ADDITION RULENumber of sitting arrangements where the two sit on the 1st table

+ Number of sitting arrangements where the two sit on the 2nd table

BY MULTIPLICATION RULEStep 1: Put the two on the first table: 1 wayStep 2: Select 4 more to join them: C(8,4)Step 3: Permute them around the table : 5!Step 4: Permute the remaining 4 circularly on 2nd table: 3!

BY MULTIPLICATION RULEStep 1: Put the two on the second table: 1 wayStep 2: Select 2 more to join them: C(8,2)Step 3: Permute them around the table: 3!Step 4: Permute remaining 6 circularly on 1st table: 5!

= (C(8,4)x5!x3!) + (C(8,2)x3!x 5!)

Example 4: 10 people are to sit around two round tables. The first table has 6 chairs, the second table

has 4 chairs.(a) How many ways can this be done?(b) How many ways can this be done if two of them need to sit together?

Page 45: Counting and probability

(b) Answer (version#2):BY ADDITION RULENumber of sitting arrangements where the two sit on the 1st table

+ Number of sitting arrangements where the two sit on the 2nd table

BY MULTIPLICATION RULEStep 1: Put the two on the first table: 1 wayStep 2: Permute 4 from 8 circularly on the 2nd table: P(8,4)/4Step 3: Permute the 6 circularly on 1st table: 5!

BY MULTIPLICATION RULEStep 1: Put the two on the second table: 1 wayStep 2: Permute 6 from 8 circularly on the 1st table: P(8,6)/6Step 3: Permute remaining 4 circularly on 2nd table: 3!

= (P(8,4)/4 x 5!) + (P(8,6)/6 x 3!)

Page 46: Counting and probability

Permutations of Sets with Repeated ElementsTheorem:Suppose a set contains•n1 indistinguishable elements of one type,•n2 indistinguishable elements of one type,and so on, through k types, where n1 + n2 + … + nk = n.

Then the number of (distinguishable) permutations of the n elements is n!/(n1!n2!…nk!).

How many eight-bit strings have exactly three 1’s?

1 2 3 3 5 6 7 8

1. Choose a subset of 3 positions out of 8to contain 1’s.

Once 1. Above has been chosen the remainingPositions are filled with 0’s.

C(8, 5) ways

1 way

Page 47: Counting and probability

How many different numbers can be formed by permuting the digits of the number

How many permutations are there of the letters in the word MISSISSIPPI?IIMSSPISSIP, ISSSPMIIPIS, PIMISSSSIIP and so on.

11!/(4!4!2!1!) = 34650

444556? 6!/(3!2!1!) = 720/(6 2 1) = 60.

Page 48: Counting and probability

R-Combinations

with repetitions allowed

Page 49: Counting and probability

• A multiset is a set, except that repetitions are allowed.• For example, {1, 1, 2, 2, 2, 3, 4} is a multiset.• An r-combination with repetitions allowed of a set of n elements is a

multiset of r objects, with each member taken from the set of n elements.

• Definition (r-combinations from a multi-set):Given a set X of n objects, an r-combination with repetition allowed (or r-combination with a multi-set of size r) is an unordered selection of elements taken from X with repetition allowed.

• Theorem: The number of r-combination with repetition allowed drawn from a set of n elements is C(r+n–1 , r).

• Example: 3-combinations from a set {a,b,c,d}– [a,a,a]; [a,a,b]; [a,a,c]; [a,a,d]– [a,b,b]; [a,b,c]; [a,b,d]; Total Number = 20 = C(3+4-1 , 3)

– [a,c,c]; [a,c,d]; [a,d,d];– [b,b,b]; [b,b,c]; [b,b,d];– [b,c,c]; [b,c,d]; [b,d,d];– [c,c,c]; [c,c,d]; [c,d,d];– [d,d,d]

Page 50: Counting and probability

Category a Category b Category c Category d

[a,a,a] X X X

[a,a,b] X X X

[a,b,d] X X X

[a,c,d] X X X

[b,c,c] X X X

[a,a,a]

[a,a,b]

[a,b,d]

[a,c,d]

[b,c,c]

Selection

X X X | | |

X X | X | |

X | X | | X

X | | X | X

| X | X X |

Represented by:Problem generalized:

• r-combination = putting r crosses

• From a set of n elements = putting n-1 ‘|’s in between crosses.

Reduces to the same problem of assigning 2-bits (X and |) to r+n-1 positions. (Permuting r+n-1 positions from a multi-set of {X,|}

Page 51: Counting and probability

• Roll three dice.

• How many different possible combinations are there? (Order does not matter.)

•n = 6, r = 3.

•C(n + r – 1, r) = C(8, 3) = 56.

•Are the 56 different combinations equally likely?

Page 52: Counting and probability

Example 1: A person giving a party wants to set out 15 assorted cans of soft drinks for his guests. He shops at a store that sells 5 different types of soft drinks(a) How many different selections of cans of 15 soft drinks can he make?(b) If root beer is one of the types of soft drinks, how many different selections include at least 6 cans of root beer?

Answer:(a) 15-combination (15 drinks) from a multi-set of 5 categories

– r = 15 drinks = 15 crosses– n = 5 categories: need 4 ‘|’ to separate the crosses– C(15+5-1 , 15) = C(19, 15) = 3876

(b) Step 1: take out 6 cans of root beer: 1 wayStep 2: select the remaining 9 cans: 9-combination (9 remaining drinks) from a multi-set of 5 categories: C(9+5-1 , 9) = C(13,9) = 715

Final Answer = 1 x 715 = 715 (Multiplication Rule)

Page 53: Counting and probability

Example 2: How many solutions are there to the equation

x1 + x2 + x3 + x4 = 10

(a) if x1, x2, x3, x4 are non-negative integers?

(b) if x1, x2, x3, x4 are positive integers?

Answer:(a) 10-combination from a multi-set of 4 categories

– r = 10 units = 10 crosses; to be distributed into…– n = 4 categories: the four variables: need 3 ‘|’ to separate the crosses– C(10+4-1 , 10) = C(13, 10) = 286

(b) Step 1: Assign 1 unit to each of the four variables: 1 way.Step 2: Assign the remaining 6 units to the four variables:

6-combination from a multi-set of 4 categories= C(6+4-1 , 6) = C(9,6) = 84

Final Answer = 1 x 84 = 84 (Multiplication Rule)

Page 54: Counting and probability

Example 3: How many triplets of the form (i,j,k) are there, when

(a) each i , j , k {1,…,n}

(b) each i , j , k {1,…,n} and 1 i j k nAnswer:(a) Permutation: n3

(b) 3-combinations from a multi-set of n categories:(Observation skills needed to relate problem to known scenario)

For example if 1 i j k 5, then we have 3-combinations from a multi-set of 5 categories: 3 X’s and 4 ‘|’s

(1,1,2) being represented as XX|X|||(1,2,4) being represented as X|X||X|(2,3,5) being represented as |X|X||X

Therefore in general, answer is C(n+3-1 , 3)= (n+2)!/ (3! x (n-1)!)= (n+2)(n+1)n / 6

Page 55: Counting and probability

The Algebra of Combinations

Page 56: Counting and probability

• Theorem: For all n 1 and 0 r < n,C(n, r) + C(n, r + 1) = C(n + 1, r + 1).

• Proof:• Basic step: n = 1.

– r must be 0.– C(1, 0) + C(1, 1) = 1 + 1 = 2.– C(2, 1) = 2.– Therefore, the statement is true for n = 1.

• Inductive step

– Assume that the statement is true for any set of n elements, for some n 1, and any r, 0 r < n.

– Let S be a set of n + 1 elements.

– Let x S.

– Each (r + 1)-combination of S either includes x or does not include x.

Page 57: Counting and probability

– Each (r + 1)-combination of S which does not include x may be viewed as an (r + 1)-combination of S – {x}.

– There are C(n, r + 1) such (r + 1)-combinations.

– For each of the (r + 1)-combinations that do include x, remove the x.

– The result is an r-combination of the S – {x}.

– There are C(n, r) such r-combinations.

– Thus, the total number of (r + 1)-combinations of S is

C(n, r) + C(n, r + 1).

– Therefore,

C(n, r) + C(n, r + 1) = C(n + 1, r + 1).

Page 58: Counting and probability

Common properties(1) C(n,r) = C(n, n-r)(2) Pascal’s Formula: C(n+1, r) = C(n, r-1) + C(n,r)

Proof of (1)• Proven Algebraically:

C(n,r) = n! / ( r! (n-r)! ) = n! / ( (n-r)! (n-(n- r))! ) = C(n, n-r)• Proven using combinatorial reasoning (p331 of text)

Let A be a set with n elements.

Let the subsets of A of size r be B1, B2,…,Bk.

Each Bk can be paired up with a subset of A of size n–r: namely A – Bk.All subsets of size n All subset of size n–r

B1 A – B1

B2 A – B2

… …

Bk A – Bk

Page 59: Counting and probability

00

10

11

21

22

21

31

32

30

33

1

1 1

1 2 1

1 3 3 1

Page 60: Counting and probability

The Binomial Theorem

Page 61: Counting and probability

• Theorem: Given any numbers a and b and any nonnegative integer n,

(a + b)n = k=0..n C(n, k)an – kbk.

• Proof: Use induction on n.

• Basic step: n = 0.

– (a + b)0 = 1.

– k=0..0 C(0, k)a0 – kbk = C(0, 0)a0b0 = 1.

– Therefore, the statement is true when n = 0.

• Inductive step

– Suppose the statement is true for some n 0.

– Then

(a + b)n + 1 = (a + b)(a + b)n

= (a + b) k=0..n C(n, k)an – kbk

= k=0..n C(n, k)an – k + 1bk

+ k=0..n C(n, k)an – kbk + 1

= an + 1 + k=1..n C(n, k)an – k + 1bk

+ k=0..n - 1 C(n, k)an – kbk + 1 + bn + 1

= an + 1 + k=1..n C(n, k)an – k + 1bk

+ k=1..n C(n, k – 1) an – k + 1bk + bn + 1

Page 62: Counting and probability

= an + 1 + k=1..n (C(n, k) + C(n, k – 1))an – k + 1bk + bn + 1

= an + 1 + k=1..n C(n + 1, k)an – k + 1bk + bn + 1

= k=0..n + 1 C(n + 1, k)an – k + 1bk.

Therefore, the statement is true for n + 1.Thus, the statement is true for all n 0.

Page 63: Counting and probability

• Binomial Theorem:

• Algebraic proof is by induction on n. (p341 of text)

• Combinatorial Proof:

(a+b)n = (a+b) (a+b) (a+b) … (a+b) (n copies)

#1 #2 #3 #n

b a a … a

a b a … a

• What is the coefficient of an-kbk ?

• How many ways can we create the an-kbk term?

• Well, to create a term, we have to select either a or b from each (a+b) group.

• Problem reduces to a n-permutation with repetitions (previous section 2.3), of 2 types of objects: selecting n-k copies of a and k copies of b: n!/(k!(n-k)!) = C(n,k)

kknn

k

n bak

nba

0

)(

Page 64: Counting and probability

A probability space is a sample space S , together with a probabilityPr[A] for each sample point w, such that

1. 2. 3. If A and B are mutually disjoint, then the probability of the union is

1)(0 AP0)( P

BifABAPBPAPBAP

BifABPAPBAP

),()()()(

),()()(