Discrete Structures for Computer Science

Similar documents
Sec$on Summary. Assigning Probabilities Probabilities of Complements and Unions of Events Conditional Probability

Discrete Probability

CSC Discrete Math I, Spring Discrete Probability

Chapter Summary. 7.1 Discrete Probability 7.2 Probability Theory 7.3 Bayes Theorem 7.4 Expected value and Variance

With Question/Answer Animations. Chapter 7

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

Probability (10A) Young Won Lim 6/12/17

CS 441 Discrete Mathematics for CS Lecture 19. Probabilities. CS 441 Discrete mathematics for CS. Probabilities

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya

CS 441 Discrete Mathematics for CS Lecture 20. Probabilities. CS 441 Discrete mathematics for CS. Probabilities

Chapter 2. Conditional Probability and Independence. 2.1 Conditional Probability

Chapter 2. Conditional Probability and Independence. 2.1 Conditional Probability

First Digit Tally Marks Final Count

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14

Discrete Probability

Great Theoretical Ideas in Computer Science

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 15 Notes. Class URL:

SDS 321: Introduction to Probability and Statistics

CS4705. Probability Review and Naïve Bayes. Slides from Dragomir Radev

Probability deals with modeling of random phenomena (phenomena or experiments whose outcomes may vary)

Conditional Probability

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

Probability Notes (A) , Fall 2010

Expected Value. Lecture A Tiefenbruck MWF 9-9:50am Center 212 Lecture B Jones MWF 2-2:50pm Center 214 Lecture C Tiefenbruck MWF 11-11:50am Center 212

Topic -2. Probability. Larson & Farber, Elementary Statistics: Picturing the World, 3e 1

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 16 Notes. Class URL:

Probability COMP 245 STATISTICS. Dr N A Heard. 1 Sample Spaces and Events Sample Spaces Events Combinations of Events...

Formalizing Probability. Choosing the Sample Space. Probability Measures

MAT Mathematics in Today's World

Lecture 10: Bayes' Theorem, Expected Value and Variance Lecturer: Lale Özkahya

CISC 1100/1400 Structures of Comp. Sci./Discrete Structures Chapter 7 Probability. Outline. Terminology and background. Arthur G.

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 10

7.1 What is it and why should we care?

Introduction and basic definitions

I - Probability. What is Probability? the chance of an event occuring. 1classical probability. 2empirical probability. 3subjective probability

Statistical Theory 1

Discrete Random Variables

5.3 Conditional Probability and Independence

Entropy. Probability and Computing. Presentation 22. Probability and Computing Presentation 22 Entropy 1/39

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

Elementary Discrete Probability

What is Probability? Probability. Sample Spaces and Events. Simple Event

2. Conditional Probability

Introduction to Probability 2017/18 Supplementary Problems

Lecture Lecture 5

Dept. of Linguistics, Indiana University Fall 2015

CMPSCI 240: Reasoning Under Uncertainty

Section 13.3 Probability

Probabilistic models

UNIT 5 ~ Probability: What Are the Chances? 1

What is a random variable

Probability Experiments, Trials, Outcomes, Sample Spaces Example 1 Example 2

Problems from Probability and Statistical Inference (9th ed.) by Hogg, Tanis and Zimmerman.

Chapter 13, Probability from Applied Finite Mathematics by Rupinder Sekhon was developed by OpenStax College, licensed by Rice University, and is

V. RANDOM VARIABLES, PROBABILITY DISTRIBUTIONS, EXPECTED VALUE

STAT:5100 (22S:193) Statistical Inference I

Probability Distributions. Conditional Probability.

MATH1231 Algebra, 2017 Chapter 9: Probability and Statistics

MODULE 2 RANDOM VARIABLE AND ITS DISTRIBUTION LECTURES DISTRIBUTION FUNCTION AND ITS PROPERTIES

Lecture 4: Probability and Discrete Random Variables

CS206 Review Sheet 3 October 24, 2018

Outline. 1. Define likelihood 2. Interpretations of likelihoods 3. Likelihood plots 4. Maximum likelihood 5. Likelihood ratio benchmarks

Probability Theory and Simulation Methods

Chapter 3 : Conditional Probability and Independence

MATH 19B FINAL EXAM PROBABILITY REVIEW PROBLEMS SPRING, 2010

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 ).

Quantitative Methods for Decision Making

6.3 Bernoulli Trials Example Consider the following random experiments

CS 361: Probability & Statistics

Discrete Random Variables

Probability Rules. MATH 130, Elements of Statistics I. J. Robert Buchanan. Fall Department of Mathematics

Randomized Algorithms

The probability of an event is viewed as a numerical measure of the chance that the event will occur.

Mathematics. ( : Focus on free Education) (Chapter 16) (Probability) (Class XI) Exercise 16.2

STA 2023 EXAM-2 Practice Problems From Chapters 4, 5, & Partly 6. With SOLUTIONS

Theorem 1.7 [Bayes' Law]: Assume that,,, are mutually disjoint events in the sample space s.t.. Then Pr( )

Statistics 251: Statistical Methods

Probabilistic models

Probability Theory. Introduction to Probability Theory. Principles of Counting Examples. Principles of Counting. Probability spaces.

Lecture 6: The Pigeonhole Principle and Probability Spaces

Conditional Probability & Independence. Conditional Probabilities

1 INFO 2950, 2 4 Feb 10

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

STA 2023 EXAM-2 Practice Problems. Ven Mudunuru. From Chapters 4, 5, & Partly 6. With SOLUTIONS

Random Variable. Discrete Random Variable. Continuous Random Variable. Discrete Random Variable. Discrete Probability Distribution

Probability: Terminology and Examples Class 2, Jeremy Orloff and Jonathan Bloom

Lower bound for sorting/probability Distributions

Probability Distributions. Conditional Probability

MATH 3C: MIDTERM 1 REVIEW. 1. Counting

Example 1. The sample space of an experiment where we flip a pair of coins is denoted by:

Lecture Notes 1 Basic Probability. Elements of Probability. Conditional probability. Sequential Calculation of Probability

Dynamic Programming Lecture #4

Some Basic Concepts of Probability and Information Theory: Pt. 1

ELEG 3143 Probability & Stochastic Process Ch. 1 Probability

Lecture notes for probability. Math 124

Probability Theory and Applications

CSE 312, 2017 Winter, W.L.Ruzzo. 5. independence [ ]

STA Module 4 Probability Concepts. Rev.F08 1

Probability 1 (MATH 11300) lecture slides

MA 250 Probability and Statistics. Nazar Khan PUCIT Lecture 15

Transcription:

Discrete Structures for Computer Science William Garrison bill@cs.pitt.edu 6311 Sennott Square Lecture #24: Probability Theory Based on materials developed by Dr. Adam Lee

Not all events are equally likely to occur Sporting events Investments Games of strategy Nature

We can model these types of real-life situations by relaxing our model of probability As before, let S be our sample space. Unlike before, we will allow S to be either finite or countable. We will require that the following conditions hold: 1. 0 p(s) 1 for each s S 2. No event can have a negative likelihood of occurrence, or more than a 100% chance of occurence In any given experiment, some event will occur The function p : S [0,1] is called a probability distribution

Recap our formulas for the probability of combinations of events Property 1: p(e) = 1 p(e) l Recall that S = E E for any event E l Further, # % & ' = 1 l So, p(s) = p(e) + p(e) = 1 l Thus, p(e) = 1 p(e) S = E E Property 2: p(e 1 E 2 ) = p(e 1 ) + p(e 2 ) p(e 1 E 2 ) l Recall that & + = #, & ' S = l Let x be some outcome in E 1 E 2 l If x is in one of E 1 or E 2, then p(x) is counted once on the RHS of the equation l If x is in both E 1 or E 2, then p(x) is counted 1 + 1 1 = 1 times on the RHS of the equation E 1 E 2

A formula for the probability of pairwise disjoint events Theorem: If E 1, E 2,, E n is a sequence of pairwise disjoint events in a sample space S, then we have: &! " ' # = )! ' # #$% Recall: E 1, E 2,, E n are pairwise disjoint iff E i E j = for 1 i,j n & #$% S = E 1 E 2 E n We can prove this theorem using mathematical induction!

How can we incorporate prior knowledge? Sometimes we want to know the probability of some event given that another event has occurred. Example: A fair coin is flipped three times. The first flip turns up tails. Given this information, what is the probability that an odd number of tails appear in the three flips? Solution: l Let F = the first flip of three comes up tails l Let E = tails comes up an odd number of times in three flips l Since F has happened, S is reduced to {THH, THT, TTH, TTT} l We know: l p(e) = E / S l = {THH, TTT} / {THH, THT, TTH, TTT} l = 2/4 l = 1/2

Conditional Probability Definition: Let E and F be events with p(f) > 0. The conditional probability of E given F, denoted p(e F), is defined as:! " # =! " #! # Intuition: l Think of the event F as reducing the sample space that can be considered l The numerator looks at the likelihood of the outcomes in E that overlap those in F l The denominator accounts for the reduction in sample size indicated by our prior knowledge that F has occurred

Bit strings Example: Suppose that a bit string of length 4 is generated at random so that each of the 16 possible 4-bit strings is equally likely to occur. What is the probability that it contains at least two consecutive 0s, given that the first bit in the string is a 0? Solution: l Let E = A 4-bit string has at least two consecutive zeros l Let F = The first bit of a 4-bit string is a zero l Want to calculate p(e F) = p(e F)/p(F) l E F = {0000, 0001, 0010, 0011, 0100} l So, p(e F) = 5/16 l Since each bit string is equally likely to occur, p(f) = 8/16 = 1/2 l So p(e F) = (5/16)/(1/2) = 10/16 = 5/8

Kids Example: What is the conditional probability that a family with two kids has two boys, given that they have at least one boy? Assume that each of the possibilities BB, BG, GB, GG is equally likely to occur. Boy is older Girl is older Solution: l Let E = A family with 2 kids has 2 boys l E = {BB} l Let F = A family with 2 kids has at least 1 boy l F = {BB, BG, GB} l E F = {BB} l So p(e F) = p(e F)/p(F) l = (1/4) / (3/4) l = 1/3

Does prior knowledge always help us? Example: Suppose a fair coin is flipped twice. Does knowing that the coin comes up tails on the first flip help you predict whether the coin will be tails on the second flip? Solution: l S = {HH, HT, TH, TT} l F = Coin was tails on the first flip = {TH, TT} l E = Coin is tails on the second flip = {TT, HT} l p(e) = 2/4 = 1/2 l p(e F) = p(e F)/p(F) l = (1/4) / (2/4) l = 1/2 l Knowing the first flip does not help you guess the second flip!

Independent Events Definition: We say that events E and F are independent if and only if p(e F) = p(e)p(f). Recall: In our last example l S = {HH, HT, TH, TT} l F = {TH, TT} l E = {HT, TT} l E F = {TT} This checks out! So: l p(e F) = E F / S l = 1/4 l p(e)p(f) = 1/2 1/2 l = 1/4

Example: Bit Strings Example: Suppose that E is the event that a randomly generated bit string of length four begins with a 1, and F is the event that this bit string contains an even number of 1s. Are E and F independent if all 4-bit strings are equally likely to occur? Solution: l By the product rule, S = 2 4 = 16 l E = {1111, 1110, 1101, 1011, 1100, 1010, 1001, 1000} l F = {0000, 0011, 0101, 0110, 1001, 1010, 1100, 1111} l So p(e) = p(f) = 8/16 = 1/2 l p(e)p(f) = 1/4 l E F = {1111, 1100, 1010, 1001} l p(e F) = 4/16 = 1/4 l Since p(e F) = p(e)p(f), E and F are independent events

Example: Distribution of kids Example: Assume that each of the four ways that a family can have two children are equally likely. Are the events E that a family with two children has two boys, and F that a family with two children has at least one boy independent? Solution: l E = {BB} l F = {BB, BG, GB} l p(e) = 1/4 l p(f) = 3/4 l p(e)p(f) = 3/16 l E F = {BB} l p(e F) = 1/4 l Since 1/4 3/16, E and F are not independent

If probabilities are independent, we can use the product rule to determine the probabilities of combinations of events Example: What is the probability of flipping heads 4 times in a row using a fair coin? Answer: p(h) = 1/2, so p(hhhh) = (1/2) 4 = 1/16 Example: What is the probability of rolling the same number 3 times in a row using an unbiased 6-sided die? Answer: l First roll agrees with itself with probability 1 l 2 nd roll agrees with first with probability 1/6 l 3 rd roll agrees with first two with probability 1/6 l So probability of rolling the same number 3 times is 1 1/6 1/6 = 1/36

In-class exercises Problem 1: What is the conditional probability that a randomly-generated 4-bit string contains two consecutive 1s, given that the first bit of the string is a 1? Problem 2: What is the conditional probability that exactly 4 heads appear when a fair coin is flipped four times, given that the first flip came up heads?

Many experiments only have two outcomes P(x) Coin flips: Heads or tails? Bit strings: 0 or 1? Predicates: T or F? These types of experiments are called Bernoulli trials Two outcomes: l Success l Failure Probability p Probability q = 1 p Many problems can be solved by examining the probability of k successes in an experiment consisting of mutuallyindependent Bernoulli trials

Example: Coin flips Example: A coin is biased so that the probability of heads is 2/3. What is the probability that exactly four heads come up when the coin is flipped seven times, assuming that each flip is independent? Solution: l l l l 2 7 = 128 possible outcomes for seven flips There are C(7,4) ways that heads can be flipped four times Since each flip is independent, the probability of each of these outcomes is (2/3) 4 (1/3) 3 So, the probability of exactly 4 heads occurring in 7 flips of this biased coin is C(7,4)(2/3) 4 (1/3) 3 = 560/2187 7 Choose 4 outcomes to make heads Probability of each heads combined using product rule Probability of each tails combined using product rule

This general reasoning provides us with a nice formula Theorem: The probability of exactly k successes in n independent Bernoulli trials, with probability of success p and probability of failure q = 1-p, is C(n,k)p k q n-k. Proof: l The outcome of n Bernoulli trials is an n-tuple (t 1, t 2,, t n ) l Each t i is either S (for success) or F (for failure) l C(n,k) ways to choose k t i s to label S l Since each trial is independent, the probability of each outcome with k successes and n-k failures is p k q n-k l So, the probability of exactly k successes is C(n,k)p k q n-k. Notation: We denote the probability of k successes in n independent Bernoulli trials with probability of success p as b(k; n, p).

Bits (Again) Example: Suppose that the probability that a 0 bit is generated is 0.9, that the probability that a 1 bit is generated is 0.1, and that bits are generated independently. What is the probability that exactly eight 0 bits are generated when ten random bits are generated? Solution: l Number of trials n = 10 l Number of successes k = 8 l Probability of success p = 0.9 l Probability of failure q = 1 0.9 = 0.1 l Want to compute b(k; 10, 0.9) l = C(10, 8)0.9 8 0.1 2 l = 0.1937102445

Many probability questions are concerned with some numerical value associated with an experiment Number of 1 bits generated Number of boys in a family Beats per minute of a heart Longevity of a chicken Number of heads flips

What is a random variable? Definition: A random variable is a function X from the sample space of an experiment to the set of real numbers R. That is, a random variable assigns a real number to each possible outcome. Note: Despite the name, X is not a variable, and is not random. X is a function! Example: Suppose that a coin is flipped three times. Let X(s) be the random variable that equals the numbers of heads that appear when s is the outcome. Then X(s) takes the following values: l X(HHH) = 3 l X(HHT) = X(HTH) = X(THH) = 2 l X(TTH) = X(THT) = X(HTT) = 1 l X(TTT) = 0

Random variables and distributions Definition: The distribution of a random variable X on a sample space S is the set of pairs (r, p(x=r)) for all r X(S), where p(x=r) is the probability that X takes the value r. Note: A distribution is usually described by specifying p(x=r) for each r X(S) Example: Assume that our coin flips from the previous slide were all equally likely to occur. We then get the following distribution for the random variable X: l p(x=0) = 1/8 l p(x=1) = 3/8 l p(x=2) = 3/8 l p(x=3) = 1/8

Example: Rolling dice Let X be the sum of the numbers that appear when a pair of fair dice is rolled. What are the values of this random variable for the 36 possible outcomes (i, j) where i and j are the numbers that appear on the first and second die, respectively? Answer: l X(1,1) = 2 p(x=2) = 1/36 l X(1,2) = X(2, 1) = 3 p(x=3) = 2/36 l X(1,3) = X(2,2) = X(3,1) = 4 p(x=4) = 3/36 l X(1,4) = X(2,3) = X(3,2) = X(4,1) = 5 p(x=5) = 4/36 l X(1,5) = X(2,4) = X(3,3) = X(4,2) = X(5,1) = 6 p(x=6) = 5/36 l X(1,6) = X(2,5) = X(3,4) = X(4,3) = X(5,2) = X(6,1) = 7 p(x=7) = 6/36 l X(2,6) = X(3,5) = X(4,4) = X(5,3) = X(6,2) = 8 p(x=8) = 5/36 l X(3,6) = X(4,5) = X(5,4) = X(6,3) = 9 p(x=9) = 4/36 l X(4,6) = X(5,5) = X(6,4) = 10 p(x=10) = 3/36 l X(5,6) = X(6,5) = 11 p(x=11) = 2/36 l X(6,6) = 12 p(x=12) = 1/36

Sometimes probabilistic reasoning can lead us to some interesting and unexpected conclusions Question: How many people need to be in the same room so that the probability of two people sharing the same birthday is greater than 1/2? Assumptions: 1. There are 366 possible birthdays 2. All birthdays are equally likely to occur 3. Birthdays are independent Solution tactic: l Find the probability p n that the n people in a room all have different birthdays l Then compute 1-p n, which is the probability that at least two people share the same birthday

Let s figure this out Let s assess probabilities as people enter the room l Person 1 clearly doesn t have the same birthday as anyone else in the room l P 2 has a different birthday than P 1 with probability 365/366 l P 3 has a different birthday than P 1 and P 2 with probability 364/366 l In general, P j has a different birthday than P 1, P 2,, P j-1 with probability [366-(j-1)]/366 = (367-j)/366 Recall that p n is the probability that n people in the room all have different birthdays. Using our above observations, this means:

But we re interested in 1-p n To check the minimum number of people need in the room to ensure that p n > 1/2, we ll use trial and error: l If n = 22, then 1 p n 0.475 l If n = 23, then 1 p n 0.506 So, you need only 23 people in a room to have a better than 50% chance that two people share the same birthday!

In-class exercises Problem 3: What is the probability that exactly 2 heads occur when a fair coin is flipped 7 times? Problem 4: Consider a game between Alice and Bob. Over time, Alice has been shown to win this game (against Bob) 75% of the time. If Alice and Bob play 6 games in a row, what is the probability that Alice wins every game? Problem 5: Consider generating a uniformly-random 4-character bit string. Also consider R, a random variable that measures the longest run of 1 bits in the generated string. Determine the distribution of R.

Final Thoughts n Today we covered l Conditional probability l Independence l Bernoulli trials l Random variables l Probabilistic analysis n Next time: l Bayes Theorem (Section 7.3)

The proof P(n) " ' $%& ( $ = ' $%& " ( $ Base case: I.H.: Inductive step: P(2): Let E 1, E 2 be disjoint events. By definition, p(e 1 E 2 ) = p(e 1 ) + p(e 2 ) p(e 1 E 2 ). Since E 1 E 2 =, p(e 1 E 2 ) = p(e 1 ) + p(e 2 ) Assume that P(k) holds for an arbitrary integer k We will now show that P(k) P(k+1) n Consider E = E 1 E 2 E k E k+1 n Let J = E 1 E 2 E k, so E = J E k+1 n p(e) = p(j E k+1 ) n = p(j) p(e k+1 ) by I.H. by definition of E n = p(e 1 E 2 E k ) p(e k+1 ) by definition of J n = p(e 1 ) p(e 2 ) p(e k ) p(e k+1 ) by I.H. Conclusion: Since we have proved the base case and the inductive case, the claim holds by mathematical induction