Introduction to Discrete Probability ICS 6D Sandy Irani
A Few Applications of Discrete Probability in Computer Science Analyzing the behavior of algorithms that make random choices Running time, performance Testing computer systems Generating input/demand to test a system Modeling discrete structures Understanding the structure of the internet or social networks
Basic Definitions Experiment: repeatable process that results in one out of a possible set of outcomes. Sample space: the set of all possible outcomes of an experiment Examples: 5-card hand from a standard deck Roll of a blue and a red die Flip a coin 3 times
Events An event is a subset of the sample space Examples: Experiment: 5-card hand from a standard deck Event: The hand has a pair of 8’s Experiment: Roll of a blue and a red die Event: The two dice have the same number Experiment: Flip a coin 3 times Event: there are more heads than tails.
Probabilities Probability over the outcomes of an experiment with sample space S p: S → ℝ such that For every x ∈ S, 0 ≤ p(x) ≤ 1 x ∈ S 𝑝(𝑥) = 1 Example: Roll of a single die. S = {1, 2, 3, 4, 5, 6} p(1) = p(2) = p(3) = p(4) = p(5) = 1 7 p(6) = 2 7
Probability of an Event Prob(E) = 𝑥 ∈𝐸 𝑝(𝑥) Example: Roll of a single die. S = {1, 2, 3, 4, 5, 6} p(1) = p(2) = p(3) = p(4) = p(5) = 1 7 p(6) = 2 7 Event: outcome is even
Uniform Distribution Experiment with sample space S The uniform distribution over S is For every x ∈ S, 𝑝 𝑥 = 1 |𝑆| If the distribution is uniform then: p(E) =
Probabilities Under the Uniform Distribution Roll a red and a blue die (Fair dice means that the distribution over the outcomes is uniform) What is |S|? What is the probability of each event: B: the sum of the dice is at most 3
Probabilities Under the Uniform Distribution Roll a fair red and blue die What is the probability of each event: C: The value on the red die is one more than the value on the blue die
Probabilities Under the Uniform Distribution Roll a fair red and blue die What is the probability of each event: D: The value on the red die is less than the value on the blue die
Probabilities Under the Uniform Distribution Flip a fair coin 3 times (Fair coin means that the distribution over the outcomes is uniform) What is |S|? What is the probability of each event: A: the first and last flip come up heads
Probabilities Under the Uniform Distribution Flip a fair coin 3 times What is the probability of each event: E: At least one flip comes up heads.
Probabilities Under the Uniform Distribution Deal a 5-card hand from a perfectly shuffled deck. (“Perfectly shuffled deck” means that the distribution over the outcomes is uniform) What is |S|?
Probabilities Under the Uniform Distribution Deal a 5-card hand from a perfectly shuffled deck. What is the probability of each event: F: the hand is a full house
Probabilities Under the Uniform Distribution Deal a 5-card hand from a perfectly shuffled deck. What is the probability of each event: T: the hand has a 2-of-a-kind
A network has 30 servers. A copy of a file is stored on 3 of the servers. A random subset of 5 of the servers go down. What is the probability that all three copies of the file are unavailable?
A group of 90 kids take a test. There are three versions of the test A group of 90 kids take a test. There are three versions of the test. The kids are grouped randomly into three groups of 30 and each group is assigned to a version of the test. What is the probability that two particular students are given the same version of the test?
A 7-bit string is selected at random A 7-bit string is selected at random. What is the probability that the string is a palindrome?
A string over the alphabet {a, b, c, d} is selected at random A string over the alphabet {a, b, c, d} is selected at random. What is the probability that the string has two consecutive characters that are the same somewhere in the string?
8 different kids are assigned 8 different jobs 8 different kids are assigned 8 different jobs. The jobs are assigned at random so that each kid gets exactly one job. One of the kids (Barnaby) has a favorite job. What is the probability that Barnaby is assigned his favorite job?