93
1 Chapter 3: Counting and Probability

Chapter 3: Counting and Probability - Binghamton … the probability is 1/2 that ... IFa counting task can be broken ... (distinguishable) dice. How many di erent combinations can

Embed Size (px)

Citation preview

1

Chapter 3: Counting and Probability

2

Motivation

3

I Probability studies the chances ofevents happening

4

For instance, the probability of:I winning the lottery

I stock prices going upI a coincidence happening

4

For instance, the probability of:I winning the lotteryI stock prices going up

I a coincidence happening

4

For instance, the probability of:I winning the lotteryI stock prices going upI a coincidence happening

5

I Counting is the basis forprobability

I Probability is the basis forstatistics (Chapter 4)

5

I Counting is the basis forprobability

I Probability is the basis forstatistics (Chapter 4)

6

Some history

The first people who studiedprobability were Frenchmathematicians Blaise Pascal andPierre de Fermat (17th century)

7

Pierre de Fermat (1601 - 1665)

8

Blaise Pascal (1623 - 1662)

9

10

11

In contrast, you need 253 peoplebefore the probability is 1/2 thatsomeone has a specific birth date,like July 4

12

Raise your hand if your birthday is:I July 4

I March 4I February 7I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4

I February 7I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7

I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7I December 25

I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7I December 25I November 14

I December 15In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

12

Raise your hand if your birthday is:I July 4I March 4I February 7I December 25I November 14I December 15

In theory, we should get about 2 or 3“coincidences”

13

Section 3.1: Counting Principles

14

We consider counting problems like:

“In how many ways can . . . bedone?”.

To do this, we need some countingprinciples.

15

Section 3.1.1: List and Count (bruteforce)

16

Sometimes you just list all thepossible ways and then count them.

17

Example

I Flip a coin, how many outcomes?

Answer: 2 possible outcomes:Heads or Tails.

I Roll a normal die, how manyoutcomes?Answer: 6 possible outcomes:r

,r r , r r r , r rr r , r rrr r , r rr rr r

17

Example

I Flip a coin, how many outcomes?Answer: 2 possible outcomes:Heads or Tails.

I Roll a normal die, how manyoutcomes?Answer: 6 possible outcomes:r

,r r , r r r , r rr r , r rrr r , r rr rr r

17

Example

I Flip a coin, how many outcomes?Answer: 2 possible outcomes:Heads or Tails.

I Roll a normal die, how manyoutcomes?

Answer: 6 possible outcomes:r,

r r , r r r , r rr r , r rrr r , r rr rr r

17

Example

I Flip a coin, how many outcomes?Answer: 2 possible outcomes:Heads or Tails.

I Roll a normal die, how manyoutcomes?Answer: 6 possible outcomes:r

,r r , r r r , r rr r , r rrr r , r rr rr r

18

Except for very small countingproblems, this is not practical.

In general, we need some elementarycounting principles that make thingseasier.

18

Except for very small countingproblems, this is not practical.

In general, we need some elementarycounting principles that make thingseasier.

19

These principles include:

Product principle: when the problemcan be broken down intoindependent steps.

Sum Principle: when the problem canbe broken down into disjointcases.

19

These principles include:Product principle: when the problem

can be broken down intoindependent steps.

Sum Principle: when the problem canbe broken down into disjointcases.

19

These principles include:Product principle: when the problem

can be broken down intoindependent steps.

Sum Principle: when the problem canbe broken down into disjointcases.

20

Complement Principle: when theproblem is the exact oppositeof another one.

21

Section 3.1.2: Product principle

22

The product principle ormultiplication rule states:

IF a counting task can be brokendown into a sequence ofindependent steps, i.e., latersteps don’t depend on choicesfrom previous steps...

22

The product principle ormultiplication rule states:

IF a counting task can be brokendown into a sequence ofindependent steps, i.e., latersteps don’t depend on choicesfrom previous steps...

23

THEN the answer is the product ofthe answers for the individualsteps.

24

Example

Roll two (distinguishable) dice. Howmany different combinations cancome up?

25

Solution

The problem can be broken downinto two steps:

I Count the number of outcomes onthe first die.There are 6.

I Count the number of outcomes onthe second die.There are also 6.

25

Solution

The problem can be broken downinto two steps:

I Count the number of outcomes onthe first die.There are 6.

I Count the number of outcomes onthe second die.There are also 6.

25

Solution

The problem can be broken downinto two steps:

I Count the number of outcomes onthe first die.There are 6.

I Count the number of outcomes onthe second die.There are also 6.

26

Solution

These steps are independent, so

by the product principle there are

6 × 6 = 36

different combinations.

26

Solution

These steps are independent, soby the product principle there are

6 × 6 = 36

different combinations.

27

28

Example

Why do bikes often have 18 differentgears? Why not 19?

28

Example

Why do bikes often have 18 differentgears? Why not 19?

29

Solution

Counting combinations of front andback gears can be broken down intotwo steps:

I Count the number of rear gears.For example there could be 6.

I Count the number of front gears.For example there could be 3.

29

Solution

Counting combinations of front andback gears can be broken down intotwo steps:

I Count the number of rear gears.For example there could be 6.

I Count the number of front gears.For example there could be 3.

29

Solution

Counting combinations of front andback gears can be broken down intotwo steps:

I Count the number of rear gears.For example there could be 6.

I Count the number of front gears.For example there could be 3.

30

Solution

By the product principle there are

6 × 3 = 18

different gears. (And we only needed6 in back and 3 in front.)

To get 19 we’d need 1 × 19 = 19,which is inconvenient.

31

Example

An ice cream parlor has 7 differentflavors. They serve either on aregular cone, sugar cone, or a dish.How many different single-scoop icecream orders are possible?

32

Solution

This can be broken down into twosteps:

I Pick a container.Can be done in 3 different ways:regular, sugar, dish.

I Pick a flavor.Can be done in 7 different ways,namely the 7 different flavors.

32

Solution

This can be broken down into twosteps:

I Pick a container.Can be done in 3 different ways:regular, sugar, dish.

I Pick a flavor.Can be done in 7 different ways,namely the 7 different flavors.

33

Solution

These are independent choices, sothe product principle says there are

7 × 3 = 21

different single-scoop ice creamorders.

34

Cont.3 ×

Flavor7 =

Order21

35

The number of steps can be morethan 2. But the product principle stillapplies as long as the steps areindependent of each other, just likehow the choice of the flavor didn’tdepend on the choice of container.

36

Example

Maria has 3 pairs of shoes, 2 skirts, 4blouses and 1 jacket. How manydifferent outfits can she assemble?(Assume an “outfit” is a pair ofshoes, a skirt, and a blouse, with thejacket optional).

37

Solution

We can view this as a 4-step process:

38

Solution

1. Pick a pair of shoes. There are 3choices.

2. Pick a skirt. There are 2 choices.3. Pick a blouse. There are 4 choices.4. Finally, decide on the jacket.

There are 2 choices (to wear ornot to wear)

38

Solution

1. Pick a pair of shoes. There are 3choices.

2. Pick a skirt. There are 2 choices.

3. Pick a blouse. There are 4 choices.4. Finally, decide on the jacket.

There are 2 choices (to wear ornot to wear)

38

Solution

1. Pick a pair of shoes. There are 3choices.

2. Pick a skirt. There are 2 choices.3. Pick a blouse. There are 4 choices.

4. Finally, decide on the jacket.There are 2 choices (to wear ornot to wear)

38

Solution

1. Pick a pair of shoes. There are 3choices.

2. Pick a skirt. There are 2 choices.3. Pick a blouse. There are 4 choices.4. Finally, decide on the jacket.

There are 2 choices (to wear ornot to wear)

39

Solution

By the product principle, this can bedone in 3 × 2 × 4 × 2 = 48 differentways. Therefore 48 different outfitscan be assembled.

Shoes3 ×

Skirt2 ×

Blouse4 ×

Jacket2 =

Outfit48

39

Solution

By the product principle, this can bedone in 3 × 2 × 4 × 2 = 48 differentways. Therefore 48 different outfitscan be assembled.

Shoes3 ×

Skirt2 ×

Blouse4 ×

Jacket2 =

Outfit48

40

When the different steps are notindependent of each other, theproduct principle may not apply.

41

Example

We are planning to drive from SantaRosa to Carbondale, eating lunchalong the way.

To go from SantaRosa to Carbondale there are threedifferent roads.

41

Example

We are planning to drive from SantaRosa to Carbondale, eating lunchalong the way. To go from SantaRosa to Carbondale there are threedifferent roads.

42

Example

I On the first road there are fourrestaurants.

I On the second road there are tworestaurants.

I On the third road there is onerestaurant.

How many alternatives do we havefor our trip?

42

Example

I On the first road there are fourrestaurants.

I On the second road there are tworestaurants.

I On the third road there is onerestaurant.

How many alternatives do we havefor our trip?

42

Example

I On the first road there are fourrestaurants.

I On the second road there are tworestaurants.

I On the third road there is onerestaurant.

How many alternatives do we havefor our trip?

42

Example

I On the first road there are fourrestaurants.

I On the second road there are tworestaurants.

I On the third road there is onerestaurant.

How many alternatives do we havefor our trip?

43

This breaks down naturally into twosteps:

I pick a road

I pick a place for lunch

but the second step depends on thechoice made for the first one!

43

This breaks down naturally into twosteps:

I pick a roadI pick a place for lunch

but the second step depends on thechoice made for the first one!

43

This breaks down naturally into twosteps:

I pick a roadI pick a place for lunch

but the second step depends on thechoice made for the first one!

44

More importantly, the number ofchoices in the second step dependson the choice made in step 1.

We can’t apply the product principle.

We’ll see later we can use the sumprinciple.

44

More importantly, the number ofchoices in the second step dependson the choice made in step 1.

We can’t apply the product principle.

We’ll see later we can use the sumprinciple.

44

More importantly, the number ofchoices in the second step dependson the choice made in step 1.

We can’t apply the product principle.

We’ll see later we can use the sumprinciple.

45

Sometimes the number of choices ina step doesn’t depend on theprevious steps, even though thechoices themselves may depend onearlier choices.

That is enough toapply the product principle.

45

Sometimes the number of choices ina step doesn’t depend on theprevious steps, even though thechoices themselves may depend onearlier choices. That is enough toapply the product principle.

46

Example

Election for President and Secretary.

Four candidates: A, B, C, and D.How many possible outcomes arethere?

46

Example

Election for President and Secretary.Four candidates: A, B, C, and D.

How many possible outcomes arethere?

46

Example

Election for President and Secretary.Four candidates: A, B, C, and D.How many possible outcomes arethere?

47

Solution

We can list the outcomes by pickingone candidate for president, and thenone of the remaining candidates forsecretary.

48

Solution

Note that the second step doesdepend on the choice for the firststep.

I If B is chosen as president then theonly choices for secretary are A, Cand D.

I But if D is chosen for presidentthen B is still a choice forsecretary.

48

Solution

Note that the second step doesdepend on the choice for the firststep.

I If B is chosen as president then theonly choices for secretary are A, Cand D.

I But if D is chosen for presidentthen B is still a choice forsecretary.

48

Solution

Note that the second step doesdepend on the choice for the firststep.

I If B is chosen as president then theonly choices for secretary are A, Cand D.

I But if D is chosen for presidentthen B is still a choice forsecretary.

49

Solution

However, regardless of the choice forpresident, there are always 3 choicesfor secretary.

The number of choicesfor step 2 is independent of step 1.The product principle applies:

President4 ×

Secretary

3 =Outcomes

12

49

Solution

However, regardless of the choice forpresident, there are always 3 choicesfor secretary. The number of choicesfor step 2 is independent of step 1.

The product principle applies:

President4 ×

Secretary

3 =Outcomes

12

49

Solution

However, regardless of the choice forpresident, there are always 3 choicesfor secretary. The number of choicesfor step 2 is independent of step 1.The product principle applies:

President4 ×

Secretary

3 =Outcomes

12

50

Product Principle

When a counting task can be brokendown into steps so that the numberof alternatives in each step is inde-pendent of the previous steps, thenthe number of ways the counting taskcan be done is the product of thenumber of ways the individual stepscan be done.