Socrative classroom: eec598ab enter SUNet now Probability for Computer Scientists CS109 Cynthia Lee Socrative classroom: 2 Today’s Topics Last week: › Conditional probability, independence › Conditional independence › Odds › Random variables, Expectation, PMF and CDF › (wow, busy week!!) TODAY: MORE EXPECTATION AND MORE DISCRETE RVS! › Expectation example › Random Variables • Bernoulli RV • What is variance? Standard deviation? • Binomial RV Rest of the week: › More random variables: discrete and then continuous eec598ab enter SUNet now Socrative classroom: eec598ab enter SUNet now Casino Examples EXPECTATION 4 Expectation example: Coin flipping In this game, you have a fair coin, and you keep flipping it until you get tails. Let n = the number of heads flipped before we get tails. Your winnings are then computed as 2n. How much would it make sense to pay to play this game? A. < $1 B. $1 - $10 C. $10 - $100 D. > $100 E. I would not agree to play this game. 5 Expectation example: Coin flipping In this game, you have a fair coin, and you keep flipping it until you get tails. Let n = the number of heads flipped before we get tails. Your winnings are then computed as 2n. How much would it make sense to pay to play this game? › Make a random variable X = your winnings › We want to find E[X], or how much we “expect” to win when we play the game. • It would make sense to pay anything up to the expected value for the game. • It would not make sense to pay any more than the expected value for the game (though that rules out nearly all casino games and state lotteries). 6 Expectation example: Coin flipping In this game, you have a fair coin, and you keep flipping it until you get tails. Let n = the number of heads flipped before we get tails. Your winnings are then computed as 2n. How much would it make sense to pay to play this game? › Make a random variable X = your winnings › We want to find E[X]: According to expectation, you should be willing to pay any amount to play this game. 7 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. Does it make sense to pay to play this game? A. Yes B. No 8 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. Does it make sense to pay to play this game? › Make a random variable Z = your winnings (for the whole strategy, so less earlier losses) › We want to find E[Z]: 9 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. Does it make sense to pay to play this game? › Make a random variable Z = your winnings (for the whole strategy, so less earlier losses) › We want to find E[Z]: Now you have E[Z], interpret it: does it make sense to pay to play this game? A. Yes B. No 10 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. Does it make sense to pay to play this game? › Make a random variable Z = your winnings (for the whole strategy, so less earlier losses) › We want to find E[Z]: Yes. You win little each time, but could play again and again and just keep accruing money. 11 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. Does it make sense to pay to play this game? › Make a random variable Z = your winnings (for the whole strategy, so less earlier losses) › We want to find E[Z]: Or No, if the opportunity cost is too high (you could make more money per hour doing something else). 12 Expectation example: Roulette In roulette, p(red) = 18/38 (18 red slots, 18 black slots, and 2 green). Your strategy is as follows: 1. Your bet Y starts at Y = $1 2. Bet Y. 3. If you win, STOP. 4. If you lose, Y *= 2 (double down), goto 2. So why doesn’t everyone just play this strategy in roulette all the time? › You can’t—you have limited amounts of money to keep doubling down. It only works if you can keep doubling down without limit. › You can’t—casinos have done this same math and set maximum bet amounts in part to prevent this strategy. › They can also just kick you out any time they don’t like what you’re doing. Variance 14 Variance Here are the PMFs for three different games › x axis is RV X = winnings › y axis is p(X=x) Which game would you play? A. First one because it has the greatest chance of maximum $ win B. Last one because it has the least chance of minimum $ win C. Doesn’t matter, they all have same E[X] D. Other/none/more than one 15 Variance DEFINITION: VARIANCE Variance Example: ship sizes Here are several observed ship sizes: › 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › We’ll line them up and rotate for easier comparison 16 Variance Example: ship sizes 17 Here are several observed ship sizes: › 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › Average = 22.075m › Now we want to calculate the square of how far from average each ship is: • (6.3 - 22.075)2 • (40.0 - 22.075)2 • … › Take the average of the above….and that’s variance • “How spread out (squared), on average?” Variance: full derivation of a more convenient formula Properties of Variance: not quite as nice as linearity of Expectation, but something… Variance Example: ship sizes 20 We add a U-Haul trailer to all the ships: › +14.5m added to each: 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › Average changes: 22.075m 36.575m › Now how much does the variance change? Variance Example: ship sizes 21 We add a U-Haul trailer to all the ships: › +14.5m added to each: 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › Average changes: 22.075m 36.575m › Now how much does the variance change? • VARIANCE DOES NOT CHANGE Variance Example: ship sizes 22 We add a U-Haul trailer to all the ships: › +14.5m added to each: 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › Average changes: 22.075m 36.575m › Now how much does the variance change? • VARIANCE DOES NOT CHANGE Variance Example: ship sizes 23 Now let’s say we want to make toy models of these ships. Each model will be 1/10th the actual size. › Actual sizes: 6.3m, 9.6m, 26.7m, 37m, 12.5m, 24m, 40m, 20.5m › New average = 22.075m / 10 = 2.2075m The new variance is ____________ the old variance. A. …more than 10x larger than… B. …10x larger than… C. …equal to… D. …1/10th of… E. …less than 1/10th of… Variance example: dice Standard Deviation: a close cousin of variance Bernoulli Trials BERNOULLI RANDOM VARIABLES Your Random Variable Quick Guide! 27 Bernoulli Random Variables In terms of p, what is E[X] for any Bernoulli random variable? A. p B. (1-p) C. p2 D. Other/none/more than one Bernoulli Random Variables Binomial Random Variables Birds of a Feather 31 Giraffe Herd Bird Flock Bernoulli RV Binomial RV Your RV Quick Reference Guide 32 Bernoulli RV If the possible values for an RV X are either 0 or 1, then X is a Bernoulli RV. (It’s black & white, because it’s boolean!) Binomial RV Is an RV that describes the behavior of n trials of a Bernoulli RV with probability p. (It’s a whole herd/flock/pride of black and white RVs!) 0/1 33 Expectation and Variance in Binomial Random Variables So easy!!!
© Copyright 2024