CMPSCI 240: Reasoning about Uncertainty

Similar documents
COMPSCI 240: Reasoning Under Uncertainty

MAT2377. Ali Karimnezhad. Version September 9, Ali Karimnezhad

CMPSCI 240: Reasoning about Uncertainty

Lecture 4: Probability and Discrete Random Variables

Combinatorial Analysis

Lecture 3: Probability

Lecture 3 : Probability II. Jonathan Marchini

BHP BILLITON UNIVERSITY OF MELBOURNE SCHOOL MATHEMATICS COMPETITION, 2003: INTERMEDIATE DIVISION

Overview. More counting Permutations Permutations of repeated distinct objects Combinations

Combinatorics. But there are some standard techniques. That s what we ll be studying.

4/17/2012. NE ( ) # of ways an event can happen NS ( ) # of events in the sample space

Probability Calculus

Lecture 2 31 Jan Logistics: see piazza site for bootcamps, ps0, bashprob

STAT 201 Chapter 5. Probability

CMPT 882 Machine Learning

Carleton University. Final Examination Fall DURATION: 2 HOURS No. of students: 275

Organization Team Team ID#

Mathematical Background

X = X X n, + X 2

CIS 2033 Lecture 5, Fall

Combinatorics and probability

CMPSCI 240: Reasoning about Uncertainty

Lecture 3. Probability and elements of combinatorics

CMPSCI 240: Reasoning Under Uncertainty

Discrete Mathematics and Probability Theory Fall 2017 Ramchandran and Rao Midterm 2 Solutions

Lecture 8: Conditional probability I: definition, independence, the tree method, sampling, chain rule for independent events

1. Basics of Information

Unit 8: Statistics. SOL Review & SOL Test * Test: Unit 8 Statistics

University of California, Berkeley, Statistics 134: Concepts of Probability. Michael Lugo, Spring Exam 1

Chapter 1. Probability

Automata Theory CS F-08 Context-Free Grammars

324 Stat Lecture Notes (1) Probability

We might divide A up into non-overlapping groups based on what dorm they live in:

3. Elementary Counting Problems 4.1,4.2. Binomial and Multinomial Theorems 2. Mathematical Induction

Learning Context Free Grammars with the Syntactic Concept Lattice

Lecture 2: Probability, conditional probability, and independence

Carleton University. Final Examination Fall DURATION: 2 HOURS No. of students: 195

Discrete Probability

Private Key Cryptography. Fermat s Little Theorem. One Time Pads. Public Key Cryptography

Permutation. Permutation. Permutation. Permutation. Permutation

University of Technology, Building and Construction Engineering Department (Undergraduate study) PROBABILITY THEORY

Notes. Combinatorics. Combinatorics II. Notes. Notes. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

7 Matrix Operations. 7.0 Matrix Multiplication + 3 = 3 = 4

Lecture 3: Latin Squares and Groups

Problem # Number of points 1 /20 2 /20 3 /20 4 /20 5 /20 6 /20 7 /20 8 /20 Total /150

1 What is the area model for multiplication?

Georgia Tech High School Math Competition

UNIT Explain about the partition of a sampling space theorem?

PROBABILITY. Contents Preface 1 1. Introduction 2 2. Combinatorial analysis 5 3. Stirling s formula 8. Preface

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 20

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 15. Random Variables: Distributions, Independence, and Expectations

MATH MW Elementary Probability Course Notes Part I: Models and Counting

CMPSCI 240: Reasoning about Uncertainty

1. When applied to an affected person, the test comes up positive in 90% of cases, and negative in 10% (these are called false negatives ).

Essential facts about NP-completeness:

Example. If 4 tickets are drawn with replacement from ,

MAT Mathematics in Today's World

Introduction to Decision Sciences Lecture 11

Carleton University. Final Examination Winter DURATION: 2 HOURS No. of students: 275

CMPSCI 250: Introduction to Computation. Lecture #11: Equivalence Relations David Mix Barrington 27 September 2013

BASICS OF PROBABILITY CHAPTER-1 CS6015-LINEAR ALGEBRA AND RANDOM PROCESSES

3/15/2010 ENGR 200. Counting

Statistics for Engineers Lecture 2

Set Notation and Axioms of Probability NOT NOT X = X = X'' = X

TWO-FACTORIZATIONS OF SMALL COMPLETE GRAPHS. F.Franek and A.Rosa, McMaster University. 1. Introduction

STEP Support Programme. Hints and Partial Solutions for Assignment 17

A Event has occurred

CIVL 7012/8012. Basic Laws and Axioms of Probability

Review problems solutions

Languages, regular languages, finite automata

Introduction to Probability with MATLAB Spring 2014

3. A square has 4 sides, so S = 4. A pentagon has 5 vertices, so P = 5. Hence, S + P = 9. = = 5 3.

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 12. Random Variables: Distribution and Expectation

NATIONAL OPEN UNIVERSITY OF NIGERIA

1 The Basic Counting Principles

CSE 103 Homework 8: Solutions November 30, var(x) = np(1 p) = P r( X ) 0.95 P r( X ) 0.

Lecture 23. Random walks

10.1. Randomness and Probability. Investigation: Flip a Coin EXAMPLE A CONDENSED LESSON

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 16. Random Variables: Distribution and Expectation

Individual Round CHMMC November 20, 2016

2!3! (9)( 8x3 ) = 960x 3 ( 720x 3 ) = 1680x 3

PROBABILITY VITTORIA SILVESTRI

Homework Solution #1. Chapter 2 2.6, 2.17, 2.24, 2.30, 2.39, 2.42, Grading policy is as follows: - Total 100

Discrete Mathematics and Probability Theory Fall 2012 Vazirani Note 14. Random Variables: Distribution and Expectation

1 Quick Sort LECTURE 7. OHSU/OGI (Winter 2009) ANALYSIS AND DESIGN OF ALGORITHMS

Discrete Mathematics for CS Spring 2006 Vazirani Lecture 22

Carleton University. Final Examination Winter DURATION: 2 HOURS No. of students: 152

Discrete Probability. Chemistry & Physics. Medicine

UC Berkeley Department of Electrical Engineering and Computer Sciences. EECS 126: Probability and Random Processes

Generating Functions

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Probabilistic models

Foundations of Neutral Geometry

Solutions I.N. Herstein- Second Edition

1 Preliminaries Sample Space and Events Interpretation of Probability... 13

Monty Hall Puzzle. Draw a tree diagram of possible choices (a possibility tree ) One for each strategy switch or no-switch

A Universal Turing Machine

Ling 289 Contingency Table Statistics

Counting Methods. CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo

DISCRETE STRUCTURES AMIN WITNO

Transcription:

CMPSCI 240: Reasoning about Uncertainty Lecture 7: More Advanced Counting Andrew McGregor University of Massachusetts Last Compiled: February 21, 2017

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

Shortcuts for Counting Permutations: There are n! = n (n 1)... 2 1 ways to permute n objects. E.g., permutations of {a, b, c} are abc, acb, bac, bca, cab, cba k-permutations: There are n (n 1)... (n k + 1) = n! (n k)! ways to choose the first k elements of a permutation of n objects. E.g., 2-permutations of {a, b, c, d} are ab, ac, ad, ba, bc, bd, ca, cb, cd, da, db, dc Combinations: There are ( ) n k = n! k!(n k)! ways to choose a subset of size k from a set of n objects. E.g., the subsets of {a, b, c, d} of size 2 are {a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}

Counting Combinations Let S be a set of n objects. How many subsets of size k are there? Every subset corresponds to k! different k-permutations, so the number of k-combinations is the number of k-permutations k! = n!/(n k)! k! which is denoted ( n k), pronounced n choose k. = n! (n k)!k!

Counting Sequences Example: Let S = {a, b, c, d} be a set of size n = 4 and consider subsets of size k = 2 Subsets of size 2 {a,b} {a,c} {a,d} {b,c} {b,d} {c,d} 2-permutations ab, ba ac, ca ad, da bc, cb bd, db cd, dc We know there are n!/(n k)! = 12 different 2-permutations and these can be arranged into groups of size k! = 2 such that each 2-permutation in the same group corresponds to the same subset of size 2. Hence, the total number of groups is n!/(n k)! 1 k! = ( 4 2) = 6.

Example: Flaming Wok Question: The Flaming Wok restaurant sells a 3-item lunch combo. You can choose from 10 different items. How many different lunch combos are there? Answer: Since your lunch is the same regardless of the order the items are put on the plate, this is a combination problem. The number of lunch combos is thus ( 10 3 ) or 120.

Example: Flaming Wok Question: Suppose you ask for a random combo and there s one item you don t like. What s the combo you order has items you like? Answer: The probability that you will like a random combo is the number of combos you like, which is ( 9 3) = 84, divided by the number of combos, which is ( ) 10 3. This gives 84/120 = 0.7.

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

Counting Partitions Consider an experiment where we divide r objects into l groups with sizes k 1, k 2,..., k l such that r = l i=1 k i. The order of items within each group doesn t matter. A combination divides items into one group of k and one group of r k and is thus a 2-partition. How many partitions are there? There are ( ) r k 1 ways to choose the objects for the first group. This leaves r k 1 objects. There are ( r k 1 ) k 2 ways to choose objects for the second group. There are ( r k 1 k 2... k l 1 ) k l ways to choose the objects for the last group.

Counting Partitions Using the counting principle, the number of partitions is thus: ( ) ( ) ( ) r r k1 r k1 k 2... k l 1 k 1 k 2 k l = r! k 1!(r k 1 )! (r k 1 )! k 2!(r k 1 k 2 )! (r k 1 k 2... k l 1 )! k l!(r k 1 k 2... k l )! Canceling terms yields the final result: r! k 1! k l!

Example: Discussion Groups Question: How many ways are there to split a discussion section of 12 students into 3 groups of 4 students each? Answer: This is a partition problem with 3 partitions of 4 objects each and 12 objects total. Using the partition counting formula, the answer is: 12! 4! 4! 4! = 12! = 34, 650 (4!) 3

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

Summary of Counting Problems Structure Description Order Matters Permutation Number of ways to order n objects Yes n! k-permutation Number of ways to form a sequence of size k using k different objects from a set of n objects Yes Combination Partition Number of ways to form a set of size k using k different objects from a set of n objects Number of ways to partition n objects into l groups of size k 1,..., k l No No Formula n! (n k)! n! k!(n k)! n! k 1! k l!

Example: Grade Assignments Question: Suppose a professor decides at the beginning of the semester that in a class of 10 students, 3 A s, 4 B s, 2 C s and one C- will be given. How many different ways can the students be assigned grades at the end of the semester? Answer: This is a partition problem. There are 10 objects and 4 groups. The group sizes are 3,4,2,1. The answer is thus: 10! 3! 4! 2! 1!

Example: Top of the class Question: A computer science program is considering offering three senior year scholarships to their top three incoming seniors worth $10, 000, $5, 000 and $2, 000. If there are 100 incoming seniors, how many ways are there for the scholarships to be awarded? Answer: This is a k-permutation problem. There are 100 students and 3 distinct scholarships. The number of assignments of students to scholarships is thus: 100! = 100 99 98 (100 3)!

Example: Binary Strings Question: How many length five binary strings are there with exactly two ones? E.g., 00011, 00101, 00110 Answer: This is a combination problem is disguise! Consider numbering the positions of a binary string {1, 2, 3, 4, 5}. If you pick a subset of these of size two and set the corresponding bits to one and the other bits to zero, you get a binary string with exactly two ones. Then the number of strings is ( ) 5 2 = 5! 3! 2! = 10

Example: Overbooked Question: Suppose a class with 50 students is scheduled in a room with only 40 seats. How many ways are there for 40 of the 50 students to get a seat. Answer: This is a combination problem. We only care if a student gets a seat, not which seat they get. The answer is thus: ( ) 50 = 50! 40 40!10!

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

PIN Codes 1 Suppose you bank insists you use a four digit PIN code. How many possible codes are there: ( ) ( ) 10 4 A : 10!/4! B : 4 10 C : D : 10 4 E : 4 10 Correct answer is D: Consider a 4 stage counting process with 10 choices at each stage.

PIN Codes 2 Suppose you bank insists you use a four digit PIN code where every number is odd. How many possible codes are there: ( ) 5 A : 1000 B : 5 10 C : 5 4 D : E : 10!/5! 4 Correct answer is C: Consider a 4 stage counting process with 5 choices at each stage.

PIN Codes 3 Suppose you bank insists you use a four digit PIN code where every number is different from the one before. How many possible codes are there: ( ) 10 A : 10 9 3 B : 10 9 C : 9 4 D : 9 9 9 E : 10!/9! 4 Correct answer is A: Consider a 4 stage counting process with 10 choices at the first stage and 9 choices are each subsequent stage.

PIN Codes 4 Suppose you bank insists you use a four digit PIN code where all the numbers are distinct. How many possible codes are there: ( ) 10 A : 10 9 3 B : 9 4 C : D : 1 E : 10 9 8 7 4 Correct answer is E: This is the number of 4-permutations of {0, 1,..., 9}.

PIN Codes 5 Suppose you bank insists you use a four digit PIN code that are palindromes, i.e., are the same read forward and backward, e.g., 1221. How many possible codes are there: A : 45 B : 89 C : 90 D : 100 E : 120 Correct answer is D: Consider the 2-stage counting process with 10 choices at both stages that specifies the first two values.

PIN Codes 6 Suppose you bank insists you use a four digit PIN code where every digit is strictly bigger than the previous digit. How many possible codes are there: ( ) 10 A : B : 10 9 8 7 C : 100 D : 10 9 3 E : 10!/6! 4 Correct answer is A: Any set of four numbers could appear in your PIN and once you ve chosen your set of four numbers, only one ordering of these numbers is valid.

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

Example: Independent Coin Flips Suppose we have a biased coin that lands heads with probability p and tails with probability (1 p). In the next section of the talk, we ll show that if we toss the coin n times then the probability that it lands heads k times is ( ) n P n (k) = p k (1 p) n k k

Outline 1 Recap 2 Partitions 3 More Examples 4 Clicker Questions 5 Bonus: Coin Flips 6 Bonus: A Harder Counting Problem

Example: Coins The commonly used coins in the USA are 1, 5, 10, and 25 cents. In a multiset, elements can be repeated, e.g., {1, 1, 5, 10}. How many multisets of 7 coins are there? E.g., {1, 1, 1, 1, 1, 1, 1} or {1, 1, 1, 5, 10, 25}... General Problem: In how many ways may we choose k elements out of a set of size n if we re allowed to repeat elements? Answer: ( ) n 1+k n 1.

Bijective Functions Definition A function f defined on domain A with range B maps each a A to exactly one element f (a) B. Definition A function f : A B is bijective if for every b B there exists a unique a such that f (a) = b. Lemma If there exists a bijection between two sets A and B then A = B. One way to show f is a bijection is to find an inverse function g such that for any b B, g(b) = a f (a) = b

Back to the the harder counting problem... Let S be the set of size k subsets of {a 1,..., a n } where elements are chosen with repetition. Define a function f : S T where T is the set of binary strings of length n 1 + k with n 1 ones. For a set s S f (s) = 0 }. {{.. 0 } 1 } 0. {{.. 0 } 1... 1 } 0. {{.. 0 } l 1 l 2 where l i is the number of copies of a i in s S. f is a bijection because there exists an inverse g defined by l n g(t) = i {m i copies of a i } where m i is the number of 0 s between (i 1)th and ith 1 in t T. Since f is a bijection we know S = T = ( ) n+k 1 n 1

Example Suppose S = {a, b, c} and we want to choose 4 elements and we re allowed to pick elements multiple times. Sequence f (s) Multiset of four items s 000011 {a,a,a,a} 000101 {a,a,a,b} 000110 {a,a,a,c} 001001 {a,a,b,b} 001010 {a,a,b,c} 001100 {a,a,c,c} 010001 {a,b,b,b} 010010 {a,b,b,c} 010100 {a,b,c,c} 011000 {a,c,c,c} 100001 {b,b,b,b} 100010 {b,b,b,c} 100100 {b,b,c,c} 101000 {b,c,c,c} 110000 {c,c,c,c}

Example: Coins The commonly used coins in the USA are 1, 5, 10, and 25 cents. How many multisets of 7 coins are there? ( ) ( ) ( ) n 1 + k 4 1 + 7 10 = = n 1 4 1 3 = 10 9 8 3 2 1 = 120 where k is the number of coins being chosen and n is the number of different types.

PIN Codes 7 Suppose you bank insists you use a four digit PIN code where every digit is at least as large as the previous digit. How many possible codes are there: ( ) ( ) ( ) ( ) 10 10 13 13 A : B : 10 9 8 7 C : D : E : 9 4 9 10 Correct answer is D: Any set multiset of four numbers could appear in your PIN and once you ve chosen these, only one ordering of these numbers is valid. There are ( ) 10 1+4 10 1 such multisets.