CS 237: Probability in Computing

Similar documents
2. Combinatorics: the systematic study of counting. The Basic Principle of Counting (BPC)

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

PROBABILITY. 1. Introduction. Candidates should able to:

November 6, Chapter 8: Probability: The Mathematics of Chance

If a regular six-sided die is rolled, the possible outcomes can be listed as {1, 2, 3, 4, 5, 6} there are 6 outcomes.

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

STAT 430/510 Probability Lecture 1: Counting-1

INDEPENDENT AND DEPENDENT EVENTS UNIT 6: PROBABILITY DAY 2

November 8, Chapter 8: Probability: The Mathematics of Chance

Discrete Structures for Computer Science

November 11, Chapter 8: Probability: The Mathematics of Chance

3 The multiplication rule/miscellaneous counting problems

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Chapter 5 - Elementary Probability Theory

Section The Multiplication Principle and Permutations

I. WHAT IS PROBABILITY?

Section : Combinations and Permutations

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

Section 6.1 #16. Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

Probability: Terminology and Examples Spring January 1, / 22

3 The multiplication rule/miscellaneous counting problems

A Probability Work Sheet

Applied Statistics I

Elementary Combinatorics

Probability and Counting Techniques

Discrete Random Variables Day 1

Math 146 Statistics for the Health Sciences Additional Exercises on Chapter 3

STAT 430/510 Probability

Chapter 1. Probability

Chapter 1. Probability

Probability (Devore Chapter Two)

Honors Precalculus Chapter 9 Summary Basic Combinatorics

Axiomatic Probability

Probability. Ms. Weinstein Probability & Statistics

Chapter 2. Permutations and Combinations

CHAPTER 2 PROBABILITY. 2.1 Sample Space. 2.2 Events

WEEK 7 REVIEW. Multiplication Principle (6.3) Combinations and Permutations (6.4) Experiments, Sample Spaces and Events (7.1)

Week 3 Classical Probability, Part I

Section Introduction to Sets

MAT104: Fundamentals of Mathematics II Counting Techniques Class Exercises Solutions

Theory of Probability - Brett Bernstein

Probability. The MEnTe Program Math Enrichment through Technology. Title V East Los Angeles College

Compound Probability. Set Theory. Basic Definitions

RANDOM EXPERIMENTS AND EVENTS

Contents 2.1 Basic Concepts of Probability Methods of Assigning Probabilities Principle of Counting - Permutation and Combination 39

Exam III Review Problems

7.4 Permutations and Combinations

Probability Theory. Mohamed I. Riffi. Islamic University of Gaza

Counting & Basic probabilities. Stat 430 Heike Hofmann

Chapter 7. Intro to Counting

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability (solutions)

Week 1: Probability models and counting

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

Combinatorics: The Fine Art of Counting

Introduction to Counting and Probability

Combinatorics: The Fine Art of Counting

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

Name. Is the game fair or not? Prove your answer with math. If the game is fair, play it 36 times and record the results.

Counting (Enumerative Combinatorics) X. Zhang, Fordham Univ.

CHAPTER 8 Additional Probability Topics

Multiple Choice Questions for Review

Problem Set 2. Counting

CS 361: Probability & Statistics

CIS 2033 Lecture 6, Spring 2017

MAT104: Fundamentals of Mathematics II Summary of Counting Techniques and Probability. Preliminary Concepts, Formulas, and Terminology

Probability. March 06, J. Boulton MDM 4U1. P(A) = n(a) n(s) Introductory Probability

The topic for the third and final major portion of the course is Probability. We will aim to make sense of statements such as the following:

Probability Rules. 2) The probability, P, of any event ranges from which of the following?

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Algebra II- Chapter 12- Test Review

Probability MAT230. Fall Discrete Mathematics. MAT230 (Discrete Math) Probability Fall / 37

Mat 344F challenge set #2 Solutions

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

1. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?

CSC/MTH 231 Discrete Structures II Spring, Homework 5

Chapter 4: Introduction to Probability

Mathematical Foundations HW 5 By 11:59pm, 12 Dec, 2015

Math 227 Elementary Statistics. Bluman 5 th edition

Bell Work. Warm-Up Exercises. Two six-sided dice are rolled. Find the probability of each sum or 7

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

CISC 1400 Discrete Structures

Raise your hand if you rode a bus within the past month. Record the number of raised hands.

S = {(1, 1), (1, 2),, (6, 6)}

Permutations and Combinations. MATH 107: Finite Mathematics University of Louisville. March 3, 2014

Math 1313 Section 6.2 Definition of Probability

Independent Events. 1. Given that the second baby is a girl, what is the. e.g. 2 The probability of bearing a boy baby is 2

Algebra 2 Notes Section 10.1: Apply the Counting Principle and Permutations

Stat210 WorkSheet#2 Chapter#2

Dependence. Math Circle. October 15, 2016

Sample Spaces, Events, Probability

Probability of Independent and Dependent Events. CCM2 Unit 6: Probability

Grade 6 Math Circles Fall Oct 14/15 Probability

Counting and Probability Math 2320

Advanced Intermediate Algebra Chapter 12 Summary INTRO TO PROBABILITY

10-1. Combinations. Vocabulary. Lesson. Mental Math. able to compute the number of subsets of size r.

1. How to identify the sample space of a probability experiment and how to identify simple events

Probability. Dr. Zhang Fordham Univ.

Lecture 6 Probability

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability

CSC/MATA67 Tutorial, Week 12

Transcription:

CS 237: Probability in Computing Wayne Snyder Computer Science Department Boston University Lecture 5: o Independence reviewed; Bayes' Rule o Counting principles and combinatorics; o Counting considered as sampling and constructing outcomes; selection with and without replacement; o Counting sequences: Enumerations and Cross-products; Permutations; K-Permutations Permutations with Duplicates Circular Permutations

Conditional Probability and Independence: Review Recall: (Conditional Probability) We can think of this as conditioning the sample space: S S = B A B A B A B

Independence and Dependence: Review Recall: (Independent Events) We say that two events A and B are independent if or, equivalently, and most importantly as we go forward: Example: What is the probability of getting HHT when flipping three fair coins? P( HHT ) = P(H) * P(H) * P(T) = ½ * ½ * ½ = 1/8. Note: Independence does not depend on physical independence, but on the mathematical relationship. However, it may indicate a lack of causality.

Independence and Dependence: Review How does this relate to tree diagrams? P(A B) considers an event B followed by an event A, and how the occurence of B affects the occurence of A. What are the labels on a tree diagram of this random experiment? B occurs (or not) A occurs (or not) P( A B ) P( A B ) = P(A B) * P(B) P( B ) P( A c B ) = 1 - P( A B ) P( A c B ) P( A c ) P( A B c ) P( A B c ) P( A c B c ) P( A c B c )

Independence and Dependence: Review When the events are independent, then we have the familiar tree diagram in which we simply write the probabilities of the events on each arc: B occurs (or not) A occurs (or not) P( A ) P( A B ) = P(A) * P(B) P( B ) P( A c ) = 1 P(A) P( A c B ) P( A c ) P( A ) P( A B c ) P( A c ) P( A c B c )

Bayes Rule We can rearrange the conditional probability rule in a way that makes the sequence of the events irrelevant -- which happened first, A or B? Or did they happen at the same time? Does it matter? We can do a little algebra to define conditional probabilities in terms of each other: so:

Bayes Rule The best way to understand this is to view it with a tree diagram! P(B A) = the probability that when A happens, it was preceeded by B: If A has happened, what is the probability that it did so on the path where B also occurred? Note: A = P( A B ) P( A B c ) So what percentage of A is due to A B? Same calculation as:

Bayes Rule This has an interesting flavor, because we can ask about causes of outcomes: A Priori Reasoning -- I randomly choose a person and observe that he is male; what the probability that it is a smoker? The first toss of a pair of dice is a 5; what is the probability that the total is greater than 8? A Posteriori Reasoning -- I find a cigarette butt on the ground, what is the probability that it was left by a man? The total of a pair of thrown dice is greater than 8; what is the probability that the first toss was a 5? This seems odd, because instead of reasoning forward from causes to effects we are reasoning backwards from effects to causes but really it is just different ways of phrasing the mathematical formulae. Time is not really relevant!

Recall the rule for finite, equiprobable probability spaces: S A To work with this definition, we will need to calculate the number of elements in A and S and we will analyze this according to how we constructed the sample points in S and in A during the random experiment. Compare with how we construct the sample space using a tree diagram!

The way in which we construct the sample space almost always follows what we might characterize as a sampling process: set (unordered) sequence (ordered)

(A) There is a basis collection of N elements that are used to create an outcome. Examples: The number of dots showing on a rolled die; letters in the alphabet, people in a group, playing cards in a standard deck. (B) K elements are selected from this collection to construct an outcome. An important distinction is: Do we put the elements back before selecting the next? (yes = with replacement ; no = without replacement ). Examples: Roll a die twice, or row 2 dice and observe the dots showing on the face; choose 5 letters, choose people for a committee, deal a poker hand. (C) The elements are used to construct an outcome, generally a sequence (a collection with an ordering, with possible duplicates), a set (an unordered collection without duplicates), (also possibly a bag or multiset (unordered collection with duplicates). Example: Collect 5 selected cards into a poker hand; arrange the 5 letters to make a word.

(A) There is a basis collection of N elements that are used to create an outcome. Examples: The number of dots showing on a rolled die; letters in the alphabet, people in a group, playing cards in a standard deck. (B) K elements are selected from this collection to construct an outcome. An important distinction is: Do we put the elements back before selecting the next? (yes = with replacement ; no = without replacement ). Examples: Roll a die twice, or row 2 dice and observe the dots showing on the face; choose 5 letters, choose people for a committee, deal a poker hand. (C) The elements are used to construct an outcome, generally a sequence (a collection with an ordering, with possible duplicates), a set (an unordered collection without duplicates), (also possibly a bag or multiset (unordered collection with duplicates)). Example: Collect 5 selected cards into a poker hand; arrange the 5 letters to make a word.

The important issues to note are (and you probably want to figure them out in this order): (i) Is the outcome ordered or unordered? Does the outcome have duplicates or not? Examples: If the two numbers showing on the dice are 2 and 5, put them in sequence [2,5] (duplicates allowed); put the 5 letters into a word (a sequence); put the 5 cards into a hand (a set). Note: in the case of [2,5] you may speak of the "first roll" or the "second roll" but in { 2,5 } you may only make statements about the collection without specifying an order ("at least one of the rolls is 5"). Words are sequences, and hands in card games are sets; otherwise you need to use context or it will be clear from the problem statement. (ii) Is the selection done with or without replacement? Examples: Selecting 5 cards for a poker hand is done without replacement (you keep the cards and don't put them back in the deck); choosing a committee of 3 from a group of 10 people is without replacement; in many cases, as with balls in a sack, it is part of the problem statement. (iii) Does the basis collection have duplicates or not? Examples: The collection of letters in "MISSISSIPPI" has duplicates, but in "WORD" there are no duplicates; two red balls in a sack are indistinguishable by color.

We will organize this along the dimensions of o ordered vs unordered and o selection with replacement vs without. and we will consider the role of duplicates when appropriate. These problems have names you should be familiar with from CS 131: For each of these I will provide a canonical problem to illustrate; I STRONGLY recommend you memorize these problems and the solution formulae, and when you see a new problem, try to translate it into one of the canonical problems.

Enumerations The simplest situation is where we are constructing a sequence with replacement, such as where the basis objects are literally replaced, or consist of information such as symbols, which can be copied without eliminating the original. Canonical Problem: You have N letters to choose from; how many words of K letters are there? Formula: N K Example: How many 10-letter words all in lower case? 26 10 A more general version of this involves counting cross-products: Generalized Enumerations: Suppose you have K sets S 1, S 2,..., S k. What is the size of the cross-product S 1 x S 2 x... x S k? Solution: S 1 * S 2 *... * S k Example: Part numbers for widgets consist of 3 upper-case letters followed by 2 digits. How many possible part numbers are there? 26 * 26 * 26 * 10 * 10 = 1,757,600

Permutations Next in order of difficulty (and not yet very difficult) are permutations, where you are constructing a sequence, but without replacement. This explains what happens when the basis set is some physical collection which can not (like letters) simply be copied from one place to another. The most basis form of permutation is simply a rearrangement of a sequence into a different order. The number of such permutations of N objects is denoted P(N,N). Canonical Problem 1(a): Suppose you have N students S 1, S 2,..., S n. In how many ways can they ALL be arranged in a sequence in N chairs? Formula: P(N,N) = N* (N-1) *... * 1 = N! Example: How many permutations of the word "COMPUTER are there? Answer: 8! = 40,320

K-Permutations If we do not simply rearrange all N objects, but consider selecting K <= N of them, and arranging these K, we have a K-Permutation indicated by P(N,K). Canonical Problem 1(b): Suppose you have N students S 1, S 2,..., S n. In how many ways can K of them be arranged in a sequence in K chairs? Formula: K terms Example: How many passwords of 8 lower-case letters and digits can be made, if you are not allowed to repeat a letter or a digit? Answer: The not allowed to repeat means essentially that you are doing this without replacement. So we have P(36,8) = 36! / 28! = 1,220,096,908,800. Note: The usual formula at the extreme right is extremely inefficient. The first formula is the most efficient, if not the shortest to write down!

Counting With and Without Order Before we discuss combinations, let us first consider the relationship between ordered sequences and unordered collections (sets or multisets) For example, consider a set A = { S, E, T } of 3 letters (all distinct). Obviously there is only such set. There are 3! = 6 different sequences of all these letters, but obviously if we can not distinguish the two O s, then not all these sequences are distinct: S E T S T E E S T E T S T S E T E S Set = unordered, no duplicates Multiset = unordered, maybe duplicates

The Unordering Principle If there are M ordered collections of N elements, then there are M/N! unordered collections of the same M elements. When all elements are distinct, as in our previous example, then obviously, M/N! = N!/N! = 1. The basic idea here is that we are correcting for the overcounting when we assumed that the ordering mattered. Therefore we divide by the number of permutations. This principle also applies to only a part of the collection: Example: Suppose we have 4 girls and 5 boys, and we want to arrange them in 9 chairs, but we do not care what order the girls are in. How many such arrangements are there? Answer: There 9! permutations, but if we do not care about the order of the (sub)collection of 4 girls, then there are 9!/4! = 15,120 such sequences.

Permutations with Repetitions As another example of the Unordering Principle, let us consider what happens if you want to form a permutation P(N,N), but the N objects are not all distinct. An example may clarify: Example: How many distinct (different looking) permutations of the word FOO are there? If we simply list all 3! = 6 permutations, we observe that because the O is duplicated, and we can not tell the difference between two occurrences of O s, there are really only 3 distinct permutations. This should be clear if we distinguish the two occurrences of O with subscripts: F O 1 O 2 FOO FOO F O 2 O 1 FOO O 1 F O 2 OFO OFO O 1 O 2 F OOF OOF O 2 F O 1 OFO O 2 O 1 F OOF Sequences: O 1 O 2 O 1 O 2 Multiset: { O, O } There are 2! sequences, so 6/2! = 6/2 = 3.

Permutations with Repetitions If you have N (non-distinct) elements, consisting of m (distinct) elements with multiplicities K 1, K 2,..., K m, that is, K 1 + K 2 +... + K m = N, then the number of distinct permutations of the N elements is Example: How many distinct (different looking) permutations of the word MISSISSIPPI are there? Solution: There are 11 letters, with multiplicities: M: 1 I: 4 S: 4 P: 2 Therefore the answer is

Circular Permutations A related idea is permutations of elements arranged in a circle. The issue here is that (by the physical arrangement in a circle) we do not care about the exact position of each elements, but only who is next to whom. Therefore, we have to correct for the overcounting by dividing by the number of possible rotations around the circle. Example: There are 6 guests to be seated at a circular table. How many arrangements of the guests are there? Hint: The idea here is that if everyone moved to the left one seat, the arrangement would be the same; it only matters who is sitting next to whom. So we must factor out the rotations. For N guests, there are N rotations of every permutation. Solution: There are 6! permutations of the guests, but for any permutation, there are 6 others in which the same guests sit next to the same people, just in different rotations. Formula: There are circular permutations of N distinct objects.