Mathematics for Computer Science MIT 6.042J/18.062J Great Expectations Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.1 Carnival Dice choose a number from 1 to 6, then roll 3 fair dice: win $1 for each match lose $1 if no match Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.6 Carnival Dice Example: choose 5, then roll 5,4,6: win $1 roll 5,4,5: win $2 roll 5,5,5: win $3 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.7 Carnival Dice Is this a fair game? Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.8 Carnival Dice # matches probability $ won 0 125/216 -1 1 75/216 1 2 15/216 2 3 1/216 3 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.10 Carnival Dice so every 216 games, expect 0 matches about 125 times 1 match about 75 times 2 matches about 15 times 3 matches about once Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.11 Carnival Dice So on average expect to win: NOT fair! 125 ( 1) 75 1 15 2 1 3 216 17 8 cents 216 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.13 Carnival Dice You can “expect” to lose 8 cents per play. But you never actually lose 8 cents on any single play, this is just your average loss. Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.14 Expected Value The expected value of random variable R is the average value of R --with values weighted by their probabilities Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.15 Expected Value The expected value of random variable R is E[R]::= ∑vPr{R = v} so for D ::= $win in Carnival 17 E[D] = 216 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.16 Sums vs Integrals We get away with sums instead of integrals because the sample space is assumed countable: ={ , 0 Copyright © Albert R. Meyer, 2008. All rights reserved. , , , } 1 n May 12, 2008 lec 14M.17 Expected Value also called mean value, mean, or expectation Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.18 Expectation for indicator I E[I] = 1 pr{I=1} + 0 pr{I=0} E[I] = pr{I=1} Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.19 Mean Time to Failure •biased coin with pr{Head} = p •flip until first Head •expected #flips? Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.20 Mean Time to Failure pr{1st H on flip 1} = p pr{1st H on flip 2} = (1-p)p 2 pr{1st H on flip 3} = (1-p) p Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.21 Mean Time to Failure E[# flips until first head] n-1 (1-p) p = ∑n>0 n n = p ∑n 0 (n+1)(1-p) 1 2 = p (1/(1-(1-p)) p Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.22 Mean Time to Failure application: Space station Mir say has 1/150,000 chance of exploding in any given hour After how may hours do we expect it to explode? 150,000 hours 17 years Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.23 Law of Total Expectation conditional expectation: E[R | A] :: v pr{R v | A} E[R] E[R | A] pr{A} E[R | A] pr{A} good for reasoning by cases Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.24 Expected time to Gamble e(n) ::= E[time with stake n] e(0) = 0 e(T) = 0 E[time with stake n | win 1st bet] = 1 + e(n+1) so by Total Expectation e(n) = p (1 + e(n+1)) + (1-p) (1 + e(n-1)) Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.25 Expected time to Gamble e(n) ::= E[time with stake n] e(0) = 0 e(T) = 0 e(n) 1 p e(n 1) e(n 1) 1 p p we know how to solve this! Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.26 Linearity of Expectation A,B random variables, a,b constants aE[A] + bE[B] = E[aA + bB] Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.30 Expected returned hats Say n people with hats leave their hats at a hat-check station. The hats get totally scrambled randomly. How many hats do we expect will be returned to their owners? Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.32 Linearity of Expectation Let Ri be indicator for ith hat being returned to its owner Then E[# hats returned] = E[∑i Ri] = ∑i E[Ri] = ∑i Pr{Ri=1} = ∑i 1/n = n(1/n) = 1 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.33 Expectation & Independence for independent R,S E[R S] = E[R] E[S] Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.34 Team Problems Problems 1 5 Copyright © Albert R. Meyer, 2008. All rights reserved. May 12, 2008 lec 14M.36
© Copyright 2025 Paperzz