18.600: lecture 11 .1in binomial random variables and...

58
18.600: Lecture 11 Binomial random variables and repeated trials Scott Sheffield MIT 18.600 Lecture 11

Upload: others

Post on 19-May-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

18.600: Lecture 11

Binomial random variables and repeatedtrials

Scott Sheffield

MIT

18.600 Lecture 11

Page 2: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 3: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 4: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 5: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 6: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 7: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 8: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 9: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 10: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 11: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Bernoulli random variables

I Toss fair coin n times. (Tosses are independent.) What is theprobability of k heads?

I Answer:(nk

)/2n.

I What if coin has p probability to be heads?

I Answer:(nk

)pk(1− p)n−k .

I Writing q = 1− p, we can write this as(nk

)pkqn−k

I Can use binomial theorem to show probabilities sum to one:

I 1 = 1n = (p + q)n =∑n

k=0

(nk

)pkqn−k .

I Number of heads is binomial random variable withparameters (n, p).

18.600 Lecture 11

Page 12: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Examples

I Toss 6 fair coins. Let X be number of heads you see. Then Xis binomial with parameters (n, p) given by (6, 1/2).

I Probability mass function for X can be computed using the6th row of Pascal’s triangle.

I If coin is biased (comes up heads with probability p 6= 1/2),we can still use the 6th row of Pascal’s triangle, but theprobability that X = i gets multiplied by pi (1− p)n−i .

18.600 Lecture 11

Page 13: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Examples

I Toss 6 fair coins. Let X be number of heads you see. Then Xis binomial with parameters (n, p) given by (6, 1/2).

I Probability mass function for X can be computed using the6th row of Pascal’s triangle.

I If coin is biased (comes up heads with probability p 6= 1/2),we can still use the 6th row of Pascal’s triangle, but theprobability that X = i gets multiplied by pi (1− p)n−i .

18.600 Lecture 11

Page 14: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Examples

I Toss 6 fair coins. Let X be number of heads you see. Then Xis binomial with parameters (n, p) given by (6, 1/2).

I Probability mass function for X can be computed using the6th row of Pascal’s triangle.

I If coin is biased (comes up heads with probability p 6= 1/2),we can still use the 6th row of Pascal’s triangle, but theprobability that X = i gets multiplied by pi (1− p)n−i .

18.600 Lecture 11

Page 15: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Other examples

I Room contains n people. What is the probability that exactlyi of them were born on a Tuesday?

I Answer: use binomial formula(ni

)piqn−i with p = 1/7 and

q = 1− p = 6/7.

I Let n = 100. Compute the probability that nobody was bornon a Tuesday.

I What is the probability that exactly 15 people were born on aTuesday?

18.600 Lecture 11

Page 16: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Other examples

I Room contains n people. What is the probability that exactlyi of them were born on a Tuesday?

I Answer: use binomial formula(ni

)piqn−i with p = 1/7 and

q = 1− p = 6/7.

I Let n = 100. Compute the probability that nobody was bornon a Tuesday.

I What is the probability that exactly 15 people were born on aTuesday?

18.600 Lecture 11

Page 17: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Other examples

I Room contains n people. What is the probability that exactlyi of them were born on a Tuesday?

I Answer: use binomial formula(ni

)piqn−i with p = 1/7 and

q = 1− p = 6/7.

I Let n = 100. Compute the probability that nobody was bornon a Tuesday.

I What is the probability that exactly 15 people were born on aTuesday?

18.600 Lecture 11

Page 18: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Other examples

I Room contains n people. What is the probability that exactlyi of them were born on a Tuesday?

I Answer: use binomial formula(ni

)piqn−i with p = 1/7 and

q = 1− p = 6/7.

I Let n = 100. Compute the probability that nobody was bornon a Tuesday.

I What is the probability that exactly 15 people were born on aTuesday?

18.600 Lecture 11

Page 19: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 20: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 21: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 22: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 23: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 24: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 25: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 26: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Expectation

I Let X be a binomial random variable with parameters (n, p).

I What is E [X ]?

I Direct approach: by definition of expectation,E [X ] =

∑ni=0 P{X = i}i .

I What happens if we modify the nth row of Pascal’s triangle bymultiplying the i term by i?

I For example, replace the 5th row (1, 5, 10, 10, 5, 1) by(0, 5, 20, 30, 20, 5). Does this remind us of an earlier row inthe triangle?

I Perhaps the prior row (1, 4, 6, 4, 1)?

18.600 Lecture 11

Page 27: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Useful Pascal’s triangle identity

I Recall that(ni

)= n×(n−1)×...×(n−i+1)

i×(i−1)×...×(1) . This implies a simple

but important identity: i(ni

)= n

(n−1i−1

).

I Using this identity (and q = 1− p), we can write

E [X ] =n∑

i=0

i

(n

i

)piqn−i =

n∑i=1

n

(n − 1

i − 1

)piqn−i .

I Rewrite this as E [X ] = np∑n

i=1

(n−1i−1

)p(i−1)q(n−1)−(i−1).

I Substitute j = i − 1 to get

E [X ] = npn−1∑j=0

(n − 1

j

)pjq(n−1)−j = np(p + q)n−1 = np.

18.600 Lecture 11

Page 28: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Useful Pascal’s triangle identity

I Recall that(ni

)= n×(n−1)×...×(n−i+1)

i×(i−1)×...×(1) . This implies a simple

but important identity: i(ni

)= n

(n−1i−1

).

I Using this identity (and q = 1− p), we can write

E [X ] =n∑

i=0

i

(n

i

)piqn−i =

n∑i=1

n

(n − 1

i − 1

)piqn−i .

I Rewrite this as E [X ] = np∑n

i=1

(n−1i−1

)p(i−1)q(n−1)−(i−1).

I Substitute j = i − 1 to get

E [X ] = npn−1∑j=0

(n − 1

j

)pjq(n−1)−j = np(p + q)n−1 = np.

18.600 Lecture 11

Page 29: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Useful Pascal’s triangle identity

I Recall that(ni

)= n×(n−1)×...×(n−i+1)

i×(i−1)×...×(1) . This implies a simple

but important identity: i(ni

)= n

(n−1i−1

).

I Using this identity (and q = 1− p), we can write

E [X ] =n∑

i=0

i

(n

i

)piqn−i =

n∑i=1

n

(n − 1

i − 1

)piqn−i .

I Rewrite this as E [X ] = np∑n

i=1

(n−1i−1

)p(i−1)q(n−1)−(i−1).

I Substitute j = i − 1 to get

E [X ] = npn−1∑j=0

(n − 1

j

)pjq(n−1)−j = np(p + q)n−1 = np.

18.600 Lecture 11

Page 30: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Useful Pascal’s triangle identity

I Recall that(ni

)= n×(n−1)×...×(n−i+1)

i×(i−1)×...×(1) . This implies a simple

but important identity: i(ni

)= n

(n−1i−1

).

I Using this identity (and q = 1− p), we can write

E [X ] =n∑

i=0

i

(n

i

)piqn−i =

n∑i=1

n

(n − 1

i − 1

)piqn−i .

I Rewrite this as E [X ] = np∑n

i=1

(n−1i−1

)p(i−1)q(n−1)−(i−1).

I Substitute j = i − 1 to get

E [X ] = npn−1∑j=0

(n − 1

j

)pjq(n−1)−j = np(p + q)n−1 = np.

18.600 Lecture 11

Page 31: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 32: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 33: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 34: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 35: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 36: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Decomposition approach to computing expectation

I Let X be a binomial random variable with parameters (n, p).Here is another way to compute E [X ].

I Think of X as representing number of heads in n tosses ofcoin that is heads with probability p.

I Write X =∑n

j=1 Xj , where Xj is 1 if the jth coin is heads, 0otherwise.

I In other words, Xj is the number of heads (zero or one) on thejth toss.

I Note that E [Xj ] = p · 1 + (1− p) · 0 = p for each j .

I Conclude by additivity of expectation that

E [X ] =n∑

j=1

E [Xj ] =n∑

j=1

p = np.

18.600 Lecture 11

Page 37: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Interesting moment computation

I Let X be binomial (n, p) and fix k ≥ 1. What is E [X k ]?

I Recall identity: i(ni

)= n

(n−1i−1

).

I Generally, E [X k ] can be written as

n∑i=0

i

(n

i

)pi (1− p)n−i ik−1.

I Identity gives

E [X k ] = npn∑

i=1

(n − 1

i − 1

)pi−1(1− p)n−i ik−1 =

npn−1∑j=0

(n − 1

j

)pj(1− p)n−1−j(j + 1)k−1.

I Thus E [X k ] = npE [(Y + 1)k−1] where Y is binomial withparameters (n − 1, p).

18.600 Lecture 11

Page 38: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Interesting moment computation

I Let X be binomial (n, p) and fix k ≥ 1. What is E [X k ]?I Recall identity: i

(ni

)= n

(n−1i−1

).

I Generally, E [X k ] can be written as

n∑i=0

i

(n

i

)pi (1− p)n−i ik−1.

I Identity gives

E [X k ] = npn∑

i=1

(n − 1

i − 1

)pi−1(1− p)n−i ik−1 =

npn−1∑j=0

(n − 1

j

)pj(1− p)n−1−j(j + 1)k−1.

I Thus E [X k ] = npE [(Y + 1)k−1] where Y is binomial withparameters (n − 1, p).

18.600 Lecture 11

Page 39: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Interesting moment computation

I Let X be binomial (n, p) and fix k ≥ 1. What is E [X k ]?I Recall identity: i

(ni

)= n

(n−1i−1

).

I Generally, E [X k ] can be written as

n∑i=0

i

(n

i

)pi (1− p)n−i ik−1.

I Identity gives

E [X k ] = npn∑

i=1

(n − 1

i − 1

)pi−1(1− p)n−i ik−1 =

npn−1∑j=0

(n − 1

j

)pj(1− p)n−1−j(j + 1)k−1.

I Thus E [X k ] = npE [(Y + 1)k−1] where Y is binomial withparameters (n − 1, p).

18.600 Lecture 11

Page 40: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Interesting moment computation

I Let X be binomial (n, p) and fix k ≥ 1. What is E [X k ]?I Recall identity: i

(ni

)= n

(n−1i−1

).

I Generally, E [X k ] can be written as

n∑i=0

i

(n

i

)pi (1− p)n−i ik−1.

I Identity gives

E [X k ] = npn∑

i=1

(n − 1

i − 1

)pi−1(1− p)n−i ik−1 =

npn−1∑j=0

(n − 1

j

)pj(1− p)n−1−j(j + 1)k−1.

I Thus E [X k ] = npE [(Y + 1)k−1] where Y is binomial withparameters (n − 1, p).

18.600 Lecture 11

Page 41: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Interesting moment computation

I Let X be binomial (n, p) and fix k ≥ 1. What is E [X k ]?I Recall identity: i

(ni

)= n

(n−1i−1

).

I Generally, E [X k ] can be written as

n∑i=0

i

(n

i

)pi (1− p)n−i ik−1.

I Identity gives

E [X k ] = npn∑

i=1

(n − 1

i − 1

)pi−1(1− p)n−i ik−1 =

npn−1∑j=0

(n − 1

j

)pj(1− p)n−1−j(j + 1)k−1.

I Thus E [X k ] = npE [(Y + 1)k−1] where Y is binomial withparameters (n − 1, p).

18.600 Lecture 11

Page 42: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 43: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 44: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 45: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 46: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 47: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 48: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Computing the variance

I Let X be binomial (n, p). What is E [X ]?

I We know E [X ] = np.

I We computed identity E [X k ] = npE [(Y + 1)k−1] where Y isbinomial with parameters (n − 1, p).

I In particular E [X 2] = npE [Y + 1] = np[(n − 1)p + 1].

I So Var[X ] = E [X 2]− E [X ]2 = np(n − 1)p + np − (np)2 =np(1− p) = npq, where q = 1− p.

I Commit to memory: variance of binomial (n, p) randomvariable is npq.

I This is n times the variance you’d get with a single coin.Coincidence?

18.600 Lecture 11

Page 49: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Compute variance with decomposition trick

I X =∑n

j=1 Xj , so

E [X 2] = E [∑n

i=1 Xi∑n

j=1 Xj ] =∑n

i=1

∑nj=1 E [XiXj ]

I E [XiXj ] is p if i = j , p2 otherwise.

I∑n

i=1

∑nj=1 E [XiXj ] has n terms equal to p and (n − 1)n

terms equal to p2.

I So E [X 2] = np + (n − 1)np2 = np + (np)2 − np2.

I ThusVar[X ] = E [X 2]− E [X ]2 = np − np2 = np(1− p) = npq.

18.600 Lecture 11

Page 50: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Compute variance with decomposition trick

I X =∑n

j=1 Xj , so

E [X 2] = E [∑n

i=1 Xi∑n

j=1 Xj ] =∑n

i=1

∑nj=1 E [XiXj ]

I E [XiXj ] is p if i = j , p2 otherwise.

I∑n

i=1

∑nj=1 E [XiXj ] has n terms equal to p and (n − 1)n

terms equal to p2.

I So E [X 2] = np + (n − 1)np2 = np + (np)2 − np2.

I ThusVar[X ] = E [X 2]− E [X ]2 = np − np2 = np(1− p) = npq.

18.600 Lecture 11

Page 51: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Compute variance with decomposition trick

I X =∑n

j=1 Xj , so

E [X 2] = E [∑n

i=1 Xi∑n

j=1 Xj ] =∑n

i=1

∑nj=1 E [XiXj ]

I E [XiXj ] is p if i = j , p2 otherwise.

I∑n

i=1

∑nj=1 E [XiXj ] has n terms equal to p and (n − 1)n

terms equal to p2.

I So E [X 2] = np + (n − 1)np2 = np + (np)2 − np2.

I ThusVar[X ] = E [X 2]− E [X ]2 = np − np2 = np(1− p) = npq.

18.600 Lecture 11

Page 52: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Compute variance with decomposition trick

I X =∑n

j=1 Xj , so

E [X 2] = E [∑n

i=1 Xi∑n

j=1 Xj ] =∑n

i=1

∑nj=1 E [XiXj ]

I E [XiXj ] is p if i = j , p2 otherwise.

I∑n

i=1

∑nj=1 E [XiXj ] has n terms equal to p and (n − 1)n

terms equal to p2.

I So E [X 2] = np + (n − 1)np2 = np + (np)2 − np2.

I ThusVar[X ] = E [X 2]− E [X ]2 = np − np2 = np(1− p) = npq.

18.600 Lecture 11

Page 53: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Compute variance with decomposition trick

I X =∑n

j=1 Xj , so

E [X 2] = E [∑n

i=1 Xi∑n

j=1 Xj ] =∑n

i=1

∑nj=1 E [XiXj ]

I E [XiXj ] is p if i = j , p2 otherwise.

I∑n

i=1

∑nj=1 E [XiXj ] has n terms equal to p and (n − 1)n

terms equal to p2.

I So E [X 2] = np + (n − 1)np2 = np + (np)2 − np2.

I ThusVar[X ] = E [X 2]− E [X ]2 = np − np2 = np(1− p) = npq.

18.600 Lecture 11

Page 54: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 55: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

Outline

Bernoulli random variables

Properties: expectation and variance

More problems

18.600 Lecture 11

Page 56: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

More examples

I An airplane seats 200, but the airline has sold 205 tickets.Each person, independently, has a .05 chance of not showingup for the flight. What is the probability that more than 200people will show up for the flight?

I In a 100 person senate, forty people always vote for theRepublicans’ position, forty people always for the Democrats’position and 20 people just toss a coin to decide which way tovote. What is the probability that a given vote is tied?

I You invite 50 friends to a party. Each one, independently, hasa 1/3 chance of showing up. What is the probability thatmore than 25 people will show up?

18.600 Lecture 11

Page 57: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

More examples

I An airplane seats 200, but the airline has sold 205 tickets.Each person, independently, has a .05 chance of not showingup for the flight. What is the probability that more than 200people will show up for the flight?

I In a 100 person senate, forty people always vote for theRepublicans’ position, forty people always for the Democrats’position and 20 people just toss a coin to decide which way tovote. What is the probability that a given vote is tied?

I You invite 50 friends to a party. Each one, independently, hasa 1/3 chance of showing up. What is the probability thatmore than 25 people will show up?

18.600 Lecture 11

Page 58: 18.600: Lecture 11 .1in Binomial random variables and ...math.mit.edu/~sheffield/600/Lecture11.pdf · 18.600: Lecture 11 Binomial random variables and repeated trials Scott She eld

More examples

I An airplane seats 200, but the airline has sold 205 tickets.Each person, independently, has a .05 chance of not showingup for the flight. What is the probability that more than 200people will show up for the flight?

I In a 100 person senate, forty people always vote for theRepublicans’ position, forty people always for the Democrats’position and 20 people just toss a coin to decide which way tovote. What is the probability that a given vote is tied?

I You invite 50 friends to a party. Each one, independently, hasa 1/3 chance of showing up. What is the probability thatmore than 25 people will show up?

18.600 Lecture 11