Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Combinatorics.

Slides:



Advertisements
Similar presentations
4/16/2015 MATH 224 – Discrete Mathematics Counting Basic counting techniques are important in many aspects of computer science. For example, consider the.
Advertisements

Counting Chapter 6 With Question/Answer Animations.
Recursively Defined Functions
THE BASIC OF COUNTING Discrete mathematics KNURE, Software department, Ph , N.V. Bilous.
Counting and Probability The outcome of a random process is sure to occur, but impossible to predict. Examples: fair coin tossing, rolling a pair of dice,
Today Today: Reading: –Read Chapter 1 by next Tuesday –Suggested problems (not to be handed in): 1.1, 1.2, 1.8, 1.10, 1.16, 1.20, 1.24, 1.28.
CSE115/ENGR160 Discrete Mathematics 04/17/12
Discrete Mathematics Lecture 7 More Probability and Counting Harper Langston New York University.
1 Discrete Math CS 280 Prof. Bart Selman Module Probability --- Part a) Introduction.
CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.
1 Section 5.1 Discrete Probability. 2 LaPlace’s definition of probability Number of successful outcomes divided by the number of possible outcomes This.
Discrete Mathematics Lecture 5
Discrete Mathematics Lecture 6 Alexander Bukharovich New York University.
Counting Elements in a List How many integers in the list from 1 to 10? How many integers in the list from m to n? (assuming m
Class notes for ISE 201 San Jose State University
1 Permutations and Combinations CS/APMA 202 Epp section 6.4 Aaron Bloomfield.
Permutations and Combinations
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Combinatorics.
Counting Chapter 6 With Question/Answer Animations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
The Basics of Counting Section 6.1.
7 Further Topics in Algebra © 2008 Pearson Addison-Wesley. All rights reserved Sections 7.4–7.7.
Basic Counting Lecture 12: Oct 28. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations,
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 6 Counting and Probability Instructor: Hayk Melikyan Today we will review sections 6.4,
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Generalized Permutations and Combinations
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
March 10, 2015Applied Discrete Mathematics Week 6: Counting 1 Permutations and Combinations How many different sets of 3 people can we pick from a group.
2 Permutations and Combinations Lesson 8 HAND OUT REFERENCE SHEET AND GO OVER IT.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
3. Counting Permutations Combinations Pigeonhole principle Elements of Probability Recurrence Relations.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Permutations and Combinations
Chapter 6, Counting and Probability
Unit 7 Permutation and Combination IT Disicipline ITD1111 Discrete Mathematics & Statistics STDTLP 1 Unit 7 Permutation and Combination.
The Basics of Counting Section 6.1.
Section Section Summary The Product Rule The Sum Rule The Subtraction Rule The Division Rule Examples, Examples, and Examples Tree Diagrams.
ICS 253: Discrete Structures I Discrete Probability King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Discrete Mathematics, 1st Edition Kevin Ferland Chapter 6 Basic Counting 1.
Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)
Introduction to Discrete Probability Epp, section 6.x CS 202.
Counting Principles Multiplication rule Permutations Combinations.
Some other set notation We will use the notation to mean that e is an element of A. We will use the notation to mean that e is not an element of A.
Permutations and Combinations. 2 In this section, techniques will be introduced for counting the unordered selections of distinct objects and the ordered.
HAWKES LEARNING Students Count. Success Matters. Copyright © 2015 by Hawkes Learning/Quant Systems, Inc. All rights reserved. Section 7.2 Counting Our.
5.5 Generalized Permutations and Combinations
Chapter 2: Probability. Section 2.1: Basic Ideas Definition: An experiment is a process that results in an outcome that cannot be predicted in advance.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Section Basic Counting Principles: The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n 1.
CS 104: Discrete Mathematics
Chapter 6 With Question/Answer Animations Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Section 6.3. Section Summary Permutations Combinations.
Counting Principles Ex. Eight pieces of paper are numbered 1 to 8 and placed in a box. One piece of paper is drawn from the box, its number is written.
ICS 253: Discrete Structures I
ICS 253: Discrete Structures I
Generalized Permutations and Combinations
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
Statistics for 8th Edition Chapter 3 Probability
CS100: Discrete structures
Basic Counting.
Standard DA-5.2 Objective: Apply permutations and combinations to find the number of possibilities of an outcome.
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Combinatorics

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction –Combinatorics is the study of the arrangement of discrete objects –Who Cares? Counting is important whenever we have finite resources Examples: –Words of memory needed to store … –Instructions needed to solve … –Number of hits per second supported by … –A password must be between six and eight characters long. The characters can be a digit or a letter (case sensitive). Each password must include at least one digit. How many passwords can we support?

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Useful Counting Cheat Sheet –Summation Notation –Summation Properties –Summation Formulas

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Basic Counting Principles (1) –Product Rule If you have two sets, A & B, |A  B| = |A| * |B| Example: How many different bit strings are there of length seven? –Answer: 2 7 Extends (by induction) to sequence of n sets –Sum Rule If you have two disjoint sets, A & B, |A  B| = |A| + |B| Example: How many ways are there to elect an ACM president if the president must be a CS faculty member (from 8) or a CS major (from 250)? –Answer: 258 Extends (by induction) to n mutually exclusive sets

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Basic Counting Principles (2) –Inclusion-Exclusion Rule If you have two arbitrary sets, A & B, |A  B| = |A| + |B| - |A  B| Example: How many bit strings of length eight start with a 1 or end with the two bits 00? –Answer: – 2 5 = 160 Subsumes the Sum Rule Extends (by induction) to n arbitrary sets (see p. 205 of text) Consider Venn Diagram

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Basic Counting Principles (3) –Extended Example: Internet Address (IPv4) Sample: (data.cs.uwec.edu) Translation: 32-bits Interpretation Restrictions – not available as netid of Class A network –All 0 s or all 1 s are not allowed as any hostid How many possible computer Internet addresses? –Note, netid for Class A is 7 bits long, netid for Class B is 14 bits long, and netid for Class C is 21 bits long if you can’t tell from the above picture. Plus some additional classes

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Basic Counting Principles (3) How many possible computer Internet addresses? Class A: ((2 7 – 1) * (2 24 – 2)) prohibited as netid Class B: (2 14 * (2 16 – 2)) + all 0’s and all 1’s prohibited Class C: (2 21 * (2 8 – 2)) = 3,737,091,842.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Counting –E.g., there are just over 4 billion people in Utopia and the area of Utopia is slightly more than 16,000 square miles. 1. How many people are there per square mile? 2 2 * 2 30 = 2 32 people 2 4 * 2 10 = 2 14 sq. miles  2 32 / 2 14 = 2 18 people per sq. mile 2. If each square mile is divided into 16 subnets, and everyone has a computer on the subnet, how many bits are necessary to identify a computer in a particular subnet? # people per subnet = 2 18 / 2 4 = 2 14  # bits = 14

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Permutations –an ordered arrangement of n elements from a set –an r-permutation is an ordered arrangement of r elements taken from a set of n elements –the number of r-permutations of n items ( n P r ) n P r = n! / (n - r)! –Example: How many ways are there to select a 1 st, 2 nd, and 3 rd place winner from 100 different people? Answer: 100 P 3 = 970,200 –Notice: n P n = n! n P 0 = 1 n P 1 = n

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Combinations –an unordered arrangement of n elements from a set unordered means order does not matter! –an r-combination is an unordered arrangement of r elements taken from a set of n elements –the number of r-combinations of n items ( n C r ) n C r = n! / r!(n - r)! = n P r / r! –Example: Quality Control wants to test 25 microprocessor chips from the 300 manufacturers. In how many ways can this be done? Answer: 300 C 25 –Notice: n C n = 1 n C 0 = 1 n C 1 = n n C r = n C n-r

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Repetition (1) –Thus far we have assumed that items can not be used twice in one draw –What if they can? Letters in a password Selecting from bag of items with copies –Permutations with repetition n PR r = n r –Combinations with repetition n CR r = n+r-1 C r –Permutations with indistinguishable objects n PI n1,n2,…,nk = n! / (n 1 !*n 2 !*…*n k !) Same as the number of ways n distinguishable objects can be distributed into k distinguishable buckets so that n i objects are in bucket i page 240 of text

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Repetition (2) –Example: Permutations with indistinguishable objects n PI n1,n2,…,nk = n! / (n 1 !*n 2 !*…*n k !) How many different strings can be made by reordering the letters of the word “SUCCESS”? We have three Ss, two Cs, one U, and one E. Notice that the three Ss can be placed into the seven positions in C(7,3) ways, leaving four blank positions The Cs can be placed into those four positions C(4,2) ways, leaving two free positions. The U can be placed into those two positions in C(2,1) ways, leaving one free position (allowing E to be placed in C(1,1) ways). From the product rule: C(7,3) * C(4,2) * C(2,1) * C(1,1) which equals (7! * 4! * 2! * 1!) / (3! * 4! * 2! * 2! * 1! * 1! * 1! * 0!) which equals 7! / (3! * 2! * 1! * 1!) which equals 420

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Repetition (3) –Extended Example: How many ways are there to build four hands of 5 cards from the standard deck of 52 cards? Solution I: Combinations of Objects –Use Combinations for each player’s hand –Use Product Rule for total 52 C 5 * 47 C 5 * 42 C 5 * 37 C 5 = 52! / (5!5!5!5!32!) Solution II: Buckets –n distinguishable objects (52 cards) –k distinguishable buckets (4 hands + 1 undealt pile) –5 cards in each hand, 32 cards in undealt pile 52! / (5!5!5!5!32!) Solution III: Permutations of Indistinguishable Objects –5 indistinguishable objects of each of four types (one for each hand) –32 indistinguishable objects of a fifth type (undealt) 52!/(5!5!5!5!32!)

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Probability (1) –An area of mathematics that has its origin in counting Developed to study gambling games –circa 1650 by Pascal –generalized circa 1812 by Laplace –Finite Probability experiment – a procedure that yields one of a given finite set of possible outcomes sample space – the finite set of possible outcomes event – a subset of the sample space The probability of an event E, which is a subset of a finite sample space S of equally likely outcomes, is p(E) = |E| / |S|

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Probability (2) –Example: What is the probability of picking a winning combination of six numbers out of 40 (no repeats)? S : set of all six-number sequences taken from 40 E : the target number |S| = 40 C 6 = 3,838,380 |E| = 1  p(E) = 1/3,838,380 (approx ) –Example: What is the probability that a hand of five cards in poker contains four of a kind? S : set of all possible poker hands E : set of all possible four-of-a-kind hands |S| = 52 C 5 = 2,598,960 |E| = nbr of ways to pick rank * nbr of ways to pick other card = 13 C 1 * 48 C 1 = 624  p(E) = 624 / 2,598,960 (approx ) product rule

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Probability (3) –Properties 0  p(E)  1 p(S) = 1 p(E) = 1 – p(E) p(E 1  E 2 ) = p(E 1 ) + p(E 2 ) – p(E 1  E 2 ) –disjoint events »p(E 1  E 2 ) = 0 »p(E 1  E 2 ) = p(E 1 ) + p(E 2 ) p(E 1  E 2 ) = p(E 1 ) * p(E 2 | E 1 ) –independent events »p(E 2 |E 1 ) = p(E 2 ) »p(E 1  E2) = p(E 1 ) * p(E 2 ) Each outcome “equally likely” implies p(a) = 1/n where a  S and |S| = n. called uniform distribution

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Expert Systems (1) –Recall expert systems use (a  (a  b))  b –Too simplistic a may or may not be known with certainty a  b may or may not be known with certainty –Alternative Approach Based on Probability Bayes’ Theorem or Creates a network of related probabilities called a Bayesian Propagation Network

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Expert Systems (2) –Concrete Example: p(D) = p(Rob has cold) = 0.2 p(S|D) = p(Rob sneezed | Rob has cold) = 0.75 p(S|D) = p(Rob sneezed | Rob does not have cold) = 0.2 p(S) = p(S|D)*p(D) + p(S|D)*p(D ) = 0.31  P(D|S) = (0.75*0.2) / 0.31 =  P(D|S) = ((1 – 0.75)*0.2) / (1 – 0.31) = Thus knowledge that Rob sneezed increased p(cold) by a factor of almost 2.5 Thus knowledge that Rob did not sneeze decreased p(cold) by a factor of almost 3.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Expert Systems (3) –Previous example assumed one hypothesis and one piece of evidence –Must generalize to n pieces of evidence and m hypotheses –Generalized Bayes’ Theorem or assumes that symptoms are conditionally independent given some decease –Frequently not the case!

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Expert Systems (4) –Example S 1 : patient sneezed S 2 : patient coughs –Suppose we observe S 1 p(D 2 |S 1 ) = 0.53, p(D 3 |S 1 ) = 0.06 –Now we observe S 2 p(D 1 |S 1 S 2 ) = 0.33, p(D 2 |S 1 S 2 ) = 0.67, p(D 3 |S 1 S 2 ) = 0.0 i = 1 (cold)i = 2 (allergy)i = 3 (light sens.) p(D i ) p(S 1 |D i ) p(S 2 |D i )

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Monte Carlo Techniques –deterministic algorithms don’t always exist or aren’t always practical –Example: Value of  Let P = set of randomly selected points –(x,y) | 0  x  1  0  y  1 Let S = { (x,y) | (x,y)  P  } Let a = | S | / | P |   4a –Example: Genetic Algorithms motivated by genetic reproduction primary operations crossover, mutate, reproduce Let v(c) represents “value” of chromosome Let v(m) be maximum such value of a population each c survives during reproduction with p = v(c)/v(m)