Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
2. Discrete Random Variables Part II: Expecta:on ECE 302 Fall 2009 TR 3‐4:15pm Purdue University, School of ECE Prof. Ilya Pollak Expected value of X: Defini:on Expected value of X: Defini:on Expected value of X: Defini:on E[X] is also called the mean of X € Example: mean of a Bernoulli random variable Example: mean of a discrete uniform random variable Example: mean of a discrete uniform random variable Example: mean of a discrete uniform random variable Example: mean of a discrete uniform random variable (Note: E[X] is not necessarily one of the values that X can assume with a non-zero probability!) Expected value: Center of gravity of PMF • Imagine that a box with weight pX(x) is placed at each x. c x Expected value: Center of gravity of PMF • Imagine that a box with weight pX(x) is placed at each x. • Center of gravity c is the point at which the sum of the torques is zero: c x Expected value: Center of gravity of PMF • Imagine that a box with weight pX(x) is placed at each x. • Center of gravity c is the point at which the sum of the torques is zero: c x Expected value: Center of gravity of PMF • Imagine that a box with weight pX(x) is placed at each x. • Center of gravity c is the point at which the sum of the torques is zero: c x Expected value: Center of gravity of PMF • Imagine that a box with weight pX(x) is placed at each x. • Center of gravity c is the point at which the sum of the torques is zero: c x Expected value and empirical mean • Many independent Bernoulli trials with p=0.2 • Bernoulli random variables X1, X2, … Expected value and empirical mean • Many independent Bernoulli trials with p=0.2 • Bernoulli random variables X1, X2, … • E[Xn]=0.2 Expected value and empirical mean • • • • Many independent Bernoulli trials with p=0.2 Bernoulli random variables X1, X2, … E[Xn]=0.2 Empirical average from many experiments close to the expected value (law of large numbers) Expected value and empirical mean • • • • Many independent Bernoulli trials with p=0.2 Bernoulli random variables X1, X2, … E[Xn]=0.2 Empirical average from many independent experiments close to the expected value (law of large numbers) What E[X] is NOT • It’s not necessarily the most likely value of X • It’s not even always the case that P(X=E[X])>0 • It’s not guaranteed to equal to the empirical average Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Two ways to evaluate E[g(X)] Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph • Is the expected value of your travel :me 60/45 = 1 hr 20 min? Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph • Is the expected value of your travel :me 60/45 = 1 hr 20 min? – NO: T = 60/V, therefore E[T] = (1/2) ∙ 60/30 + (1/2) ∙ 60/60 = 1 hr 30 min Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph • Is the expected value of your travel :me 60/45 = 1 hr 20 min? – NO: T = 60/V, therefore E[T] = (1/2) ∙ 60/30 + (1/2) ∙ 60/60 = 1 hr 30 min – Because you have equal chances to spend 1 hour or 2 hours driving. Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph • Is the expected value of your travel :me 60/45 = 1 hr 20 min? – NO: T = 60/V, therefore E[T] = (1/2) ∙ 60/30 + (1/2) ∙ 60/60 = 1 hr 30 min – Because you have equal chances to spend 1 hour or 2 hours driving. • Interpreta:on: in N independent repe::ons of the trip, – You would expect to spend a total of 1.5N hours driving Cau:on: In general, E[g(X)]≠g(E[X]) • Example: average speed vs average :me. • Suppose you need to drive 60 miles. A very bad storm will hit your area with probability 1/2. – If the storm hits, you will drive 30 miles/hour during the en:re trip; – If the storm does not hit, you will do 60 miles/hour during the en:re trip. • What’s the expected value of your speed? – (1/2) ∙ 30 + (1/2) ∙ 60 = 45 mph • Is the expected value of your travel :me 60/45 = 1 hr 20 min? – NO: T = 60/V, therefore E[T] = (1/2) ∙ 60/30 + (1/2) ∙ 60/60 = 1 hr 30 min – Because you have equal chances to spend 1 hour or 2 hours driving. • Interpreta:on: in N independent repe::ons of the trip – You would expect to spend a total of 1.5N hours driving – Your average speed per trip (not per unit :me traveled!) would be about 45mph What is the meaning of E[b] if b is a non‐random number? What is the meaning of E[b] if b is a non‐random number? Linearity of expecta:on Variance and Standard Devia:on of X: Defini:ons [ var(X ) = E ( X − E[X ]) 2 ] Variance and Standard Devia:on of X: Defini:ons [ var(X ) = E ( X − E[X ]) 2 ] Variance and Standard Devia:on of X: Defini:ons [ var(X ) = E ( X − E[X ]) 2 ] Calcula:ng var(X) [ 2 ] 2 var(X ) = E ( X − E[X ]) = ∑ (x − E[X ]) pX (x) x Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x € x x Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x x x = ∑ x 2 pX (x) − 2E[X]∑ xpX (x) + (E[X ]) 2 ∑ pX (x) x € € x x Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x x x = ∑ x 2 pX (x) − 2E[X]∑ xpX (x) + (E[X ]) 2 ∑ pX (x) x x x € € E[X 2 ] E[X ] 1 Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x € € x x = ∑ x 2 pX (x)−2E[X]∑ xpX (x) + (E[X ]) 2 ∑ pX (x) x x x E[ X ] E[ X 2 ] 1 −( E[ X ]) 2 Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x € x = ∑ x 2 pX (x)−2E[X]∑ xpX (x) + (E[X ]) 2 ∑ pX (x) x x x E[ X ] E[ X 2 ] 1 −( E[ X ]) 2 = E[X 2 ] − (E[X]) 2 € € x Calcula:ng var(X) var(X ) = E [( X − E[X ]) ] = ∑ (x − E[X ]) p (x) 2 2 X x = ∑ ( x 2 − 2xE[X ] + (E[X ]) 2 ) pX (x) x = ∑ x 2 pX (x) − 2∑ xE[X ]pX (x) + ∑ (E[X ]) 2 pX (x) x € x x = ∑ x 2 pX (x)−2E[X]∑ xpX (x) + (E[X ]) 2 ∑ pX (x) x x x E[ X ] E[ X 2 ] 1 −( E[ X ]) 2 = E[X 2 ] − (E[X]) 2 € € [ Sometimes this is easier to compute than E ( X − E[X ]) 2 ] Example 2.4: Variance of a Bernoulli random variable Example 2.4: Variance of a Bernoulli random variable Example 2.4: Variance of a Bernoulli random variable Example 2.4: Variance of a Bernoulli random variable € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b How to compute the expectation and variance of this random variable? € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T How to compute the expectation and variance of this random variable? € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T € How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T € € How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b E[Y] = E[X](a − b) + b = p(a − b) + b € € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b E[Y] = E[X](a − b) + b = p(a − b) + b E[Y 2 ] = E[X 2 (a − b) 2 + 2X(a − b)b + b 2 ] € € € € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b E[Y] = E[X](a − b) + b = p(a − b) + b E[Y 2 ] = E[X 2 (a − b) 2 + 2X(a − b)b + b 2 ] € = E[X 2 ](a − b) 2 + 2E[X](a − b)b + b 2 € € € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b E[Y] = E[X](a − b) + b = p(a − b) + b E[Y 2 ] = E[X 2 (a − b) 2 + 2X(a − b)b + b 2 ] € = E[X 2 ](a − b) 2 + 2E[X](a − b)b + b 2 = p(a − b)€2 + 2 p(a − b)b + b 2 € € € Another Bernoulli random variable Toss a coin with P(H) = p, and let a if H Y = b if T p if k = a Then pY (k) = 1− p if k = b Note : Y − b 1 if H = =X a − b 0 if T How to compute the expectation and variance of this random variable? Therefore, Y = X(a − b) + b E[Y] = E[X](a − b) + b = p(a − b) + b E[Y 2 ] = p(a − b) 2 + 2 p(a − b)b + b 2 2 € var(Y ) = E[Y ] − (E[Y ]) 2 = ( p − p 2 )(a − b) € Standard devia:on as measurement error • Run a series of independent, iden:cal experiments, e.g., Bernoulli trials. • Empirically es:mate the probability of an event, say, the success in a Bernoulli trial, as the number of successes divided by the number of experiments. • Standard devia:on answers the following ques:on: In many experiments, by how much would we expect our es:mate to deviate from the actual probability of success? • For example, if p=0.2, then E[X] = 0.2 and var(X)=0.16. Root mean‐square devia:on of the es:mate of p from 0.2, as a func:on of the number of trials Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. • Expected profit for 2 is $500. Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. • Expected profit for 2 is $500. • But clearly the two opportuni:es are very different: you risk a lot under the first one, whereas the second one is riskless. Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. • Expected profit for 2 is $500. • But clearly the two opportuni:es are very different: you risk a lot under the first one, whereas the second one is riskless. • Standard devia:on characterizes the risk: – Opportunity 1: st.dev. = (0.5(500+1000)2 + 0.5(500‐2000)2)1/2 = 1500 Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. • Expected profit for 2 is $500. • But clearly the two opportuni:es are very different: you risk a lot under the first one, whereas the second one is riskless. • Standard devia:on characterizes the risk: – Opportunity 1: st.dev. = (0.5(500+1000)2 + 0.5(500‐2000)2)1/2 = 1500 – Opportunity 2: st.dev. = (1(500‐500)2)1/2 = 0 Standard devia:on as risk • Suppose you have two investment opportuni:es: – Opportunity 1: invest $1000, have equal chances of a total wipeout or of $2000 profit – Opportunity 2: invest $1000, earn $500 profit guaranteed. • Expected profit for 1 is 0.5(‐$1000) + 0.5($2000) = $500. • Expected profit for 2 is $500. • But clearly the two opportuni:es are very different: you risk a lot under the first one, whereas the second one is riskless. • Standard devia:on characterizes the risk: – Opportunity 1: st.dev. = (0.5(500+1000)2 + 0.5(500‐2000)2)1/2 = 1500 – Opportunity 2: st.dev. = (1(500‐500)2)1/2 = 0 • Standard devia:on characterizes the spread of possible profits around the expected profit. Problem 2.20: Expecta:on and variance of a geometric random variable As an ad campaign, a chocolate factory places golden :ckets in some of its candy bars, with the promise that a golden :cket is worth a trip through the chocolate factory, and all the chocolate you can eat for life. If the probability of finding a gold :cket is p, find the mean and the variance of the number of candy bars you need to eat to find a :cket. Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise € Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 € € Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp € Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp € Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp ∞ d € Therefore, E[C] = − p∑ {(1− p) k } dp k =1 Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp ∞ ∞ d d k k € Therefore, E[C] = − p∑ {(1− p) } = − p ∑ (1− p) dp k =1 k =1 dp Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp ∞ ∞ d d k k € Therefore, E[C] = − p∑ {(1− p) } = − p ∑ (1− p) dp k =1 k =1 dp d 1− p = −p dp p Mean of a geometric random variable • Let C = # candy bars un:l 1st success • Model C as geometric with parameter p: (1− p) k−1 p, k = 1,2,… pC (k) = 0, otherwise ∞ E[C] = ∑ k(1− p) k−1 p k=1 d k−1 € Useful fact : k(1− p) = − {(1− p) k } dp ∞ ∞ d d k k € Therefore, E[C] = − p∑ {(1− p) } = − p ∑ (1− p) dp k =1 k =1 dp 1 1 d 1− p = −p = − p− 2 = dp p p p How many candy bars un:l first success? • If there are five golden :ckets per 1,000,000 bars, then p=1/200,000. How many candy bars un:l first success? • If there are five golden :ckets per 1,000,000 bars, then p=1/200,000. • [Note: we assume an infinite number of bars so that C is truly geometric.] How many candy bars un:l first success? • If there are five golden :ckets per 1,000,000 bars, then p=1/200,000. • [Note: we assume an infinite number of bars so that C is truly geometric.] • Then E[C] = 200,000. How many candy bars un:l first success? • If there are five golden :ckets per 1,000,000 bars, then p=1/200,000. • [Note: we assume an infinite number of bars so that C is truly geometric.] • Then E[C] = 200,000. • On average, have to buy 200,000 chocolate bars un:l first success. € 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 € € 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp € € 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] € € € 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] ∞ 2 ∞ d d 2 k +1 k E [C ] = p 2 ∑ (1− p) + p ∑ (1− p) dp k =1 dp k =1 € € € 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] ∞ 2 ∞ d d 2 k +1 k E [C ] = p 2 ∑ (1− p) + p ∑ (1− p) dp k =1 dp k =1 (1− p )2 / p −1/ p 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) € k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] ∞ 2 ∞ d d 2 k +1 k E [C ] = p 2 ∑ (1− p) + p ∑ (1− p) dp k =1 dp k =1 € (1− p )2 / p d2 1 = p 2 −2+ dp p € € 1 p − p −1/ p 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) € k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] ∞ 2 ∞ d d 2 k +1 k E [C ] = p 2 ∑ (1− p) + p ∑ (1− p) dp k =1 dp k =1 € (1− p )2 / p d2 1 = p 2 −2+ dp p € € −1/ p 1 1 d 1 p − = p − 2 + 1 − dp p p p 2 E[C ] ∞ E [C ] = ∑ k 2 (1− p) k−1 p 2 k=1 2 Another useful fact : k (1− p) € k−1 d2 d k +1 = 2 {(1− p) } + {(1− p) k } dp dp [Because the right - hand side is (k + 1)k(1− p) k−1 − k(1− p) k−1 .] ∞ 2 ∞ d d 2 k +1 k E [C ] = p 2 ∑ (1− p) + p ∑ (1− p) dp k =1 dp k =1 € (1− p )2 / p d2 1 = p 2 −2+ dp p € € −1/ p 1 1 2p 1 2 1 d 1 p − = p − 2 + 1 − = 3 − = 2 − dp p p p p p p p Variance of a geometric random variable 2 2 1 1 1 1 2 2 var(C) = E [C ] − ( E[C]) = 2 − − = 2 − p p p p p € Variance of a geometric random variable 2 2 1 1 1 1 2 2 var(C) = E [C ] − ( E[C]) = 2 − − = 2 − p p p p p € € If p = 1/200,000, the standard deviation is 200,000 2 − 200,000 ≈ 200,000 Thus, your actual number candy bars until first success may be quite far from the mean!