STAT 302 Intro to Probability Alexandre Bouchard-Côté www.stat.ubc.ca/~bouchard/courses/stat302-fa2019-20/ Announcement • Extra office hour: Thursday, 3pm, ESB 4182 Variance Ex. 40 Compare these 3 ‘games’ • X = ... Same expectation lose $1,000 with pr 1/2 • (zero), but very • win $1,000 with pr 1/2 different risks! • Y = ... • lose $1 with pr 1/2 • win $1 with pr 1/2 • Z = No amount is exchanged with pr 1 Def 13 Variance • A measure of how ‘risky’ a r.v. is • In other words how much does it deviate from its mean, in expectation? • New notation: • Var[X] = E[ ( X - E[X] ) • Examples on the board... 2 ] Prop 11 Useful properties (*) • Var(X) = • 2 E[X ] - 2 (E[X]) Var(aX+b) = a2 Var(X) Ex. 40b Example • Value X of a volatile stock after 1 year: • $1 with probability p = 1/3 • $0 with probability p = 2/3 • X ~ ??? A. 1/3 • Var[X] ? B. 2/3 C. 0 D. 2/9 Variance of Bern(p) Linearity Recall: Ex 35d Where is ‘linearity’ useful? Find: E[S] = E[X1 + X2] ‘Brute force way’ B1 ~ Unif({0, 1/2, 1}) B2 ~ Unif({0, 1/2}) 1/2 X1 | B1 ~ Bern(B1) X2 | B2 ~ Bern(B2) (B1 = 0) (.., B2 = 1/2) 1/2 1/2 1/2 S = X1 + X2 1/2 1/2 1/3 1/3 1 (.., B2 = 0) (B1 = 1/2) 1/2 (.., B2 = 0) 1/2 1/4 (.., B2 = 1/2) 1/2 * 1/6 + (..., S = 0) * 1/12 + (..., S = 0) (..., S = 1) * 1/12 + (..., S = 0) * 1/12 + (..., S = 1) * 1/12 + (..., S = 0) * 1/24 + (..., S = 1) * 1/12 + (..., S = 2) * 1/24 + 1/4 1/3 1/2 (B1 = 1) (.., B2 = 0) 1/2 1 * 1/6 + (..., S = 1) * 1/12 + (..., S = 1) 1/2 (.., B2 = 1/2) 1/2 (..., S = 2) * 1/12 Recall: Ex 35d Where is ‘linearity’ useful? Find: E[S] = E[X1 + X2] B1 ~ Unif({0, 1/2, 1}) B2 ~ Unif({0, 1/2}) X1 | B1 ~ Bern(B1) X2 | B2 ~ Bern(B2) S = X1 + X2 Shortcut: 1) Compute E[X1] 2) Compute E[X2] 3) When can we write E[X1 + X2] = E[X1] + E[X2] ?? Always!! Independence NOT needed Ex 35d - Shortcut way Where is ‘linearity’ useful? B1 ~ Unif({0, 1/2, 1}) B2 ~ Unif({0, 1/2}) 1) Compute E[X1] = 1/2 X1 | B1 ~ Bern(B1) X2 | B2 ~ Bern(B2) S = X1 + X2 1 (B1 = 0) (..., X1 = 0) 1/3 1/3 1/2 1/3 (B1 = 1/2) (.., X1 = 0) 1/6 1/2 (.., X1 = 1) 1/6 1/3 1 (B1 = 1) (.., X1 = 1) 1/3 Ex 35d - Shortcut way Where is ‘linearity’ useful? B1 ~ Unif({0, 1/2, 1}) B2 ~ Unif({0, 1/2}) X1 | B1 ~ Bern(B1) X2 | B2 ~ Bern(B2) 1) Compute E[X1] = 1/2 2) Compute E[X2] = 1/4 S = X1 + X2 1/2 (B2 = 0) 1 1/2 1/2 (B2 = 1/2) (..., X2 = 0) 1/2 (.., X2 = 0) 1/4 1/2 (.., X2 = 1) 1/4 Ex 35d - Shortcut way Where is ‘linearity’ useful? B1 ~ Unif({0, 1/2, 1}) B2 ~ Unif({0, 1/2}) 1) Compute E[X1] = 1/2 X1 | B1 ~ Bern(B1) X2 | B2 ~ Bern(B2) 2) Compute E[X2] = 1/4 S = X1 + X2 3) Use linearity! E[S] = E[X1 + X2] = E[X1] + E[X2] = 3/4 Linearity for expectation E[X1 + X2] = E[X1] + E[X2] For all random variables X1 and X2 Linearity for variance? Prop 10 Linearity for expectation E[X1 + X2] = E[X1] + E[X2] For all random variables X1 and X2 Linearity for variance Var[X1 + X2] = Var[X1] + Var[X2] If the random variables X1 and X2 are independent Computing expectation with ‘joint PMFs’ Computing E[Y] when Y = g(X1, X2) Slower Faster g(x1, x2) = x1 + x2 ? YES E[X1+X2] = E[X1]+E[X2] NO A few other shortcuts that we will cover later (ignore for now) ‘Joint PMF’ Two ‘default’ methods (always work) Covering this one today or Ex 35d (B1 = 0) Method of Ex53d: find PMF of Y using a decision tree 1/2 1/2 (.., B2 = 1/2) 1/3 1/2 1/2 1/2 1/3 1 (.., B2 = 0) 1/2 (B1 = 1/2) 1/2 (.., B2 = 0) 1/2 1/4 (.., B2 = 1/2) 1/2 (..., S = 0) * 1/6 + * 1/12 + (..., S = 1) * 1/12 + (..., S = 0) * 1/12 + (..., S = 1) * 1/12 + (..., S = 0) (..., S = 1) * 1/24 + * 1/12 + (..., S = 2) * 1/24 + (..., S = 1) * 1/6 + * 1/12 + (..., S = 0) 1/4 1/3 1/2 (B1 = 1) (.., B2 = 0) 1/2 1 (..., S = 1) 1/2 (.., B2 = 1/2) 1/2 (..., S = 2) * 1/12 Prop 9 (version 2) Expectation when Y=g(X1, X2) • You know: • P(X = x , X • Y = g(X , X ) 1 1 1 This is called the joint PMF, p(x1, x2) 2 Definition = x2) E[Y] = 2 y ∈ Image(Y) Second method: E[Y] = ∑ ∑ g(x1,x2) * P(X1 = x1, X2 = x2) Im ) X2 e( ag 1) Im (X ∈ x 2 age ∈ x1 Def 14 ∑ y * P(Y = y) One more shortcut • If: • g(x , x ) = x , ie. we want the expectation of the product, E[X1X2] 1 •X 1 E[X1X2] = and X2 are independent ∑ ∑ x1 x2 x1 = 1 x2 2 x2 * P(X1 = x1, X2 = x2) ∑ x1 P(X1 = x1) ∑ x2 x1 = E[X1]E[X2] x2 P(X2 = x2) Geometric PMF (‘distribution’) Ex 45 Motivating example • You need to hire 1 person • You can only interview one random person per business day • This person will be qualified for the job and hired with independent probability 2/3 • What is the probability you succeed in 3 business days or less? A.2/3 B.2/27 C.26/27 D.26/31 Decision tree 1/3 1/3 2/3 Do not find employee on day 1 2/3 (X1 = 0) Find employee on day 1 (X1 = 1) 2/3 (T = 1) 1/3 Do not find employee on 2/3 day 2 (.., X2 = 0) Find employee on day 2 (..., X2 = 1) 2/9 (T = 2) Do not find employee on day 3 (.., X3 = 0) 1/3 2/3 Find employee on day 3 (..., X3 = 1) 2/27 (T = 3) Geometric PMF This gives us a new PMF! P (X = k) = (1 0.4 0.3 0.2 0.1 0.0 Approximation of P(Y = k) 0.5 0.6 Probability Mass Function (PMF) 4 6 8 k 1 p k in 1, 2, 3, ... What do we need to check? 2 p)k 10 12 14 Polya distribution Also known as negative binomial Ex 46 Motivating example • You need to hire 3 people • You can only interview one random person per business day • This person will be qualified for the job and hired with independent probability 2/3 • What is the probability you succeed in exactly 6 business days If T’ = # of days, compute P(T’ = 6) Note: there are several ways (paths) to hire 3 people in exactly 6 days # people # people days days P(T’=6) = P(X1=0, X2=0, X3=0, ..., X6=1) + P (X1=1, X2=0, X3=1 ..., X6=1) + ... If T’ = # of days, compute P(T’ = 6) Is this a valid path in (T’ = 6) ? # people days NO: here T’ = 5 ! Probability of one path # people • Chain rule • Recall: Events A and B are independent if: P(A ∩ B) = P(A) * P(B) • Equivalent definition (when P(B) > 0): Events A and B are independent if: P(A | B) = P(A) 0) 3= (X * P 0) 2= (X ) * P =0 X1 P( P (X1=0, X2=0, X3=0 ..., X6=1) = 3 (1/3)3 (2/3) = ... days If T’ = # of days, compute P(T’ = 6) P(T’=6) = P (X1=0, X2=0, X3=0 ..., X6=1) + P (X1=1, X2=0, X3=1 ..., X6=1) + .. = number of paths * probability of each path ??? (2/3)3 (1/3)3 Counting • How many scenarios lead to a 6 days hiring process? • Notes: • Each scenario ends in X = 1 • Assign the remaining two 1’s among the 6 remaining five Xi’s If T’ = # of days, compute P(T’ = 6) Note: there are several ways (paths) to hire 3 people in exactly 6 days 4 5 # people # people 1 3 days days {4, 5} {1, 3} Polya PMF This gives us a new PMF! 1 r p (1 1 p) i r i in r, r+1, r+2, ... 0.05 0.10 0.15 0.20 0.25 0.30 Probability Mass Function (PMF) 0.00 i r ◆ Approximation of P(Y = k) P (X = i) = ✓ 5 10 15 k 20