Top Banner

of 23

ch4- Counting principle

Apr 04, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/29/2019 ch4- Counting principle

    1/23

    R. JohnsonbaughDiscrete Mathematics

    5th edition, 2001

    Chapter 4

    Counting methodsand the pigeonhole principle

  • 7/29/2019 ch4- Counting principle

    2/23

    4.1 Basic principles

    Multiplication principle

    If an activity can be performed in k

    successive steps,

    Step 1 can be done in n1 ways

    Step 2 can be done in n2 ways

    Step k can be done in nk ways

    Then: the number of different ways that the

    activity can be performed is the product

    n1n2nk

  • 7/29/2019 ch4- Counting principle

    3/23

    Addition principle

    Let X1, X2,, Xk be a collection of k

    pairwise disjoint sets, each of which has nj

    elements, 1 < j < k, then the union of

    those setsk

    X = Xjj =1

    has n1 + n2+ + nk elements

  • 7/29/2019 ch4- Counting principle

    4/23

    4.2 Permutations and combinations

    A permutationof n distinct elements x1, x2,, xnis an ordering of the n elements. There are n!

    permutations of n elements.

    Example: there are 3! = 6 permutations of three

    elements a, b, c:

    abc bac cab

    acb bca cba

  • 7/29/2019 ch4- Counting principle

    5/23

    r-permutations

    An r-permutation of n distinct elementsis anordering of an r-element subset of the n

    elements x1, x2,, xn

    Theorem 4.2.10:

    For r < n the number of r-permutations of a set

    with n distinct objects isP(n,r) = n(n-1)(n-2)(n-r+1) = n !/(n-r) !

    If r = n, P(n,n) = n !

  • 7/29/2019 ch4- Counting principle

    6/23

    Combinations

    Let X = {x1, x2,, xn} be a set containing n

    distinct elements

    An r-combinationof X is an unorderedselection of r elements of X, for r < n

    The number of r-combinations of X is the

    binomial coefficient

    C(n,r) = = n! / r!(n-r)! = P(n,r)/ r!

  • 7/29/2019 ch4- Counting principle

    7/23

    Catalan numbers

    Eugene-Charles Catalan (1814-1894)

    Catalan numbersare defined by the formula

    Cn

    = C(2n,n) / (n+1)

    for n = 0, 1, 2,

    The first few terms are:

    n 0 1 2 3 4 5 6 7 8 9 10Cn 1 1 2 5 14 42 132 429 1430 4862 16796

  • 7/29/2019 ch4- Counting principle

    8/23

    4.3 Algorithms for generating

    permutations and combinations

    Lexicographic order:

    Given two strings = s1s2sp and = t1t2tq Define < if

    p < q and si = tifor all i = 1, 2,, p

    Or for some i, si t

    iand for the smallest i, s

    i< t

    i

    Example: if = 1324, = 1332, = 132,

    then < and < .

  • 7/29/2019 ch4- Counting principle

    9/23

    4.4 Introduction to

    discrete probability

    An experiment is a process that yields an

    outcome

    An event is an outcome or a set of outcomes

    from an experiment

    The sample space is the event of all possibleoutcomes

  • 7/29/2019 ch4- Counting principle

    10/23

    Probability

    Probability of an eventis the number ofoutcomes in the event divided by the number of

    outcomes in the sample space.

    If S is a finite sample space and E is an event

    (E is a subset of S) then the probability of E is

    P(E) = |E| / |S|

  • 7/29/2019 ch4- Counting principle

    11/23

    4.5 Discrete probability theory

    When all outcomes are equally likely and

    there are n possible outcomes, each one

    has a probability 1/n.

    BUT this is not always the case. When

    all probabilities are not equal, then some

    probability (possibly different numbers)must be assigned to each outcome.

  • 7/29/2019 ch4- Counting principle

    12/23

    Probability function

    A probability functionP is a function fromthe set of all outcomes (sample space S) tothe interval [0, 1], in symbols

    P : S [0, 1]

    The probability of an eventE S is the sumof the probabilities of every outcome in E

    P(E) = P(x)x E

  • 7/29/2019 ch4- Counting principle

    13/23

    Probability of an event

    Given E S, we have

    0 < P(E) < P(S) = 1

    If S = {x1

    , x2

    ,, xn

    } is a sample space, then

    n

    P(S) = P(xi) = 1

    i =1

    If Ec is the complement of E in S, then

    P(E) + P(Ec) = 1

  • 7/29/2019 ch4- Counting principle

    14/23

    Events in a sample space

    Given any two events E1 and E2 in a sample

    space S. Then

    P(E1 E2) = P(E1) + P(E2) P(E1E2)

    We also have P() = 0

    Events E1 and E2 are mutually exclusive if and

    only if E1E2 = . In this case

    P(E1E2) = P(E1) + P(E2)

  • 7/29/2019 ch4- Counting principle

    15/23

    Conditional probability

    Conditional probability is the probability of an

    event E, given that another event F has

    occurred, is called. In symbols P(E|F).

    If P(F) > 0 then

    P(E|F) = P(EF) / P(F)

    Two events E and F are independent if

    P(EF) = P(E)P(F)

  • 7/29/2019 ch4- Counting principle

    16/23

    Pattern recognition Pattern recognitionplaces items into classes,

    based on various featuresof the items.

    Given a set of features F we can calculate the

    probability of a class C, given F: P(C|F) Place the item into the most probable class, i.e.

    the one C for which P(C|F) is the highest. Example: Wine can be classified as Table wine (T), Premium (R)

    or Swill (S). Let F {acidity, body, color, price} Suppose a wine has feature F, and P(T|F) = 0.5, P(R|F) = 0.2

    and P(S|F) = 0.3. Since P(T|F) is the highest number, this wine

    will be classified as table wine.

  • 7/29/2019 ch4- Counting principle

    17/23

    Bayes Theorem

    Given pairwise disjoint classes C1, C2,,

    Cn and a feature set F, then

    P(Cj|F) = A / B, where

    A = P(F|Cj)P(Cj)

    n

    and B = P(F|Ci)P(Ci)i = 1

  • 7/29/2019 ch4- Counting principle

    18/23

    Generalized permutations

    and combinations

    Theorem 4.6.2: Suppose that a sequence of n

    items has nj identical objects of type j,for 1< j < k. Then the number of orderings of S

    is

    ____n!____

    n1!n2!...nk!

    4 7 Bi i l ffi i t

  • 7/29/2019 ch4- Counting principle

    19/23

    4.7 Binomial coefficients

    and combinatorial identities

    Theorem 4.7.1: Binomial theorem. For any realnumbers a, b, and a nonnegative integer n:

    (a+b)n = C(n,0)anb0 + C(n,1)an-1b1+

    + C(n,n-1)a1bn-1 + C(n,n)a0bn

    n

    (a+b)n = C(n,k) an-k bkk = 0

    Theorem 4.7.6: For 1 < k < n,

    C(n+1,k) = C(n,k) + C(n,k-1) andn

    C(i,k) = C(n+1,k+1)i = k

  • 7/29/2019 ch4- Counting principle

    20/23

    Pascals Triangle

    1

    1 1

    1 2 1

    1 3 3 1

    1 4 6 4 1

    1 5 10 10 5 1

    1 6 15 20 15 6 1

    1 7 21 35 35 21 7 1

    1 8 28 56 70 56 28 8 1

    1 9 36 84 126 126 84 36 9 1

  • 7/29/2019 ch4- Counting principle

    21/23

    4.8 The pigeonhole principle

    First form: If k < n and n pigeons fly into kpigeonholes, some pigeonhole contains at least

    two pigeons.

  • 7/29/2019 ch4- Counting principle

    22/23

    Second form of the

    pigeonhole principle

    If X and Y are finite sets with |X| > |Y| and

    f : X Y is a function, then f(x1) = f(x2) forsome x1, x2 X, x1 x2.

  • 7/29/2019 ch4- Counting principle

    23/23

    Third form of the

    pigeonhole principle

    If X and Y are finite sets with |X| = n, |Y| = m

    and k = n/m, then there are at least k valuesa1, a2,, ak X such that f(a1) = f(a2) = f(ak).

    Example:

    n = 5, m = 3

    k = n/m = 5/3 = 2.