Mathematics for Computer Science MIT 6.042J/18.062J Great Expectations Copyright © Radhika Nagpal, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal
Abstractions in Probability Random Variables R(s) = r Probability Distribution Pr (R=r) Expected Value
Expected Value Fortune Telling Average of future values
Definition Expected value of a random variable R
A Simple Example R = value thrown by a dice Expected value of R = 1(1/6) + 2(1/6) + 3 (1/6) + 4(1/6) + 5(1/6) + 6(1/6) = 3.5
Example 2: Space Station Mir Suppose that main computer has a probability p of failing every second When do we expect it to first fail?
Space Station Mir T = time of the first failure E[T] = 1 . Pr (fails on the 1st second, T=1) + 2 . Pr (fails on the on 2nd second, T=2) + 3 . Pr (fails on the 3rd second, T=3) ….
Space Station Mir Pr (fails on the 1st second, T=1) = p Pr (fails on the on 2nd second, T=2) = (1-p) p Pr (fails on the 3rd second, T=3) = (1-p) (1-p) p
Space Station Mir Probability that it fails on ith second Pr (T=i) = (1-p)i-1 p no failures in first i-1 seconds
Space Station Mir similar to geometric series
More About Mir How many times should I expect to roll a fair dice before I get a 6? 6 times Mir contains 10,000 components How many failures do we expect to see per year of operation?
Other Applications Algorithms Gambling Analysis of sorting: given a sequence of n numbers, on average how many numbers are out of order? Gambling Will the Patriots win the Superbowl? How many rounds of 5 card draw do I expect to play before I finally win?
Pitfalls of Expectation Expected value does not tell us the distribution Expected value may never actually occur Model is not Reality
In Class Problems 1 and 2
Example 2: Birthday Problem In a class with 100 people, what is the probability that two people have the same birthday? 99% How many pairs of people with the same birthday do we expect to see?
Actual Data 12 pairs in entire class Dates: Should you expect to see something similar in other classes? Jan 24, Jan 25, Feb 16, Feb 23 Mar 6, Mar 17, Mar 22 Jul 6, Jul 12, Aug 19 Oct 13, Oct 25
Birthday Problem R = number of pairs with same birthday Pr (R = 0) Pr (exactly one pair, R=1) Pr (exactly two pairs, R=2) = ? Starts becoming very messy …
Linearity of Expectation
Birthdays Let Ri = 1 if ith pair has same birthday, = 0 if not Pr (Ri = 1) = 1/365 Pr (Ri = 0) = 1 – (1/365) E[Ri] = 1 (1/365) = 1/365 = 1/Y
Expected Number of Birthday Pairs E[# of Pairs] = E[R1] + E[R2] + E[R3]…. = (n choose 2) . E[Ri] = n2 / 2Y ~ 14 pairs for 6.042
The Same Question N wireless devices randomly pick identifiers from a range R. How many identifier collisions do you expect to see?
The Same Question N wireless devices randomly pick identifiers from a range R. How many identifier collisions do you expect to see? = N2 / 2R
Experiment: The Hat Check Game: Everyone puts there name in a hat, then each person randomly draws out a name. How many people expect to get their own name back? Collect stats per table