18.440: lecture 10 .1in variance and standard...

69
18.440: Lecture 10 Variance and standard deviation Scott Sheffield MIT 18.440 Lecture 10

Upload: others

Post on 21-May-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

18.440: Lecture 10

Variance and standard deviation

Scott Sheffield

MIT

18.440 Lecture 10

Page 2: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 3: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 4: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 5: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 6: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 7: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 8: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 9: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Recall definitions for expectation

I Recall: a random variable X is a function from the state spaceto the real numbers.

I Can interpret X as a quantity whose value depends on theoutcome of an experiment.

I Say X is a discrete random variable if (with probability one)it takes one of a countable set of values.

I For each a in this countable set, write p(a) := P{X = a}.Call p the probability mass function.

I The expectation of X , written E [X ], is defined by

E [X ] =∑

x :p(x)>0

xp(x).

I Also,E [g(X )] =

∑x :p(x)>0

g(x)p(x).

18.440 Lecture 10

Page 10: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Defining variance

I Let X be a random variable with mean µ.

I The variance of X , denoted Var(X ), is defined byVar(X ) = E [(X − µ)2].

I Taking g(x) = (x − µ)2, and recalling thatE [g(X )] =

∑x :p(x)>0 g(x)p(x), we find that

Var[X ] =∑

x :p(x)>0

(x − µ)2p(x).

I Variance is one way to measure the amount a random variable“varies” from its mean over successive trials.

18.440 Lecture 10

Page 11: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Defining variance

I Let X be a random variable with mean µ.

I The variance of X , denoted Var(X ), is defined byVar(X ) = E [(X − µ)2].

I Taking g(x) = (x − µ)2, and recalling thatE [g(X )] =

∑x :p(x)>0 g(x)p(x), we find that

Var[X ] =∑

x :p(x)>0

(x − µ)2p(x).

I Variance is one way to measure the amount a random variable“varies” from its mean over successive trials.

18.440 Lecture 10

Page 12: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Defining variance

I Let X be a random variable with mean µ.

I The variance of X , denoted Var(X ), is defined byVar(X ) = E [(X − µ)2].

I Taking g(x) = (x − µ)2, and recalling thatE [g(X )] =

∑x :p(x)>0 g(x)p(x), we find that

Var[X ] =∑

x :p(x)>0

(x − µ)2p(x).

I Variance is one way to measure the amount a random variable“varies” from its mean over successive trials.

18.440 Lecture 10

Page 13: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Defining variance

I Let X be a random variable with mean µ.

I The variance of X , denoted Var(X ), is defined byVar(X ) = E [(X − µ)2].

I Taking g(x) = (x − µ)2, and recalling thatE [g(X )] =

∑x :p(x)>0 g(x)p(x), we find that

Var[X ] =∑

x :p(x)>0

(x − µ)2p(x).

I Variance is one way to measure the amount a random variable“varies” from its mean over successive trials.

18.440 Lecture 10

Page 14: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 15: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 16: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 17: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 18: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 19: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Very important alternate formula

I Let X be a random variable with mean µ.

I We introduced above the formula Var(X ) = E [(X − µ)2].

I This can be written Var[X ] = E [X 2 − 2Xµ+ µ2].

I By additivity of expectation, this is the same asE [X 2]− 2µE [X ] + µ2 = E [X 2]− µ2.

I This gives us our very important alternate formula:Var[X ] = E [X 2]− (E [X ])2.

I Original formula gives intuitive idea of what variance is(expected square of difference from mean). But we will oftenuse this alternate formula when we have to actually computethe variance.

18.440 Lecture 10

Page 20: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 21: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 22: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Variance examples

I If X is number on a standard die roll, what is Var[X ]?

I Var[X ] = E [X 2]− E [X ]2 =1612 + 1

622 + 1632 + 1

642 + 1652 + 1

662 − (7/2)2 = 916 −

494 = 35

12 .

I Let Y be number of heads in two fair coin tosses. What isVar[Y ]?

I Recall P{Y = 0} = 1/4 and P{Y = 1} = 1/2 andP{Y = 2} = 1/4.

I Then Var[Y ] = E [Y 2]− E [Y ]2 = 1402 + 1

212 + 1422 − 12 = 1

2 .

18.440 Lecture 10

Page 23: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Variance examples

I If X is number on a standard die roll, what is Var[X ]?

I Var[X ] = E [X 2]− E [X ]2 =1612 + 1

622 + 1632 + 1

642 + 1652 + 1

662 − (7/2)2 = 916 −

494 = 35

12 .

I Let Y be number of heads in two fair coin tosses. What isVar[Y ]?

I Recall P{Y = 0} = 1/4 and P{Y = 1} = 1/2 andP{Y = 2} = 1/4.

I Then Var[Y ] = E [Y 2]− E [Y ]2 = 1402 + 1

212 + 1422 − 12 = 1

2 .

18.440 Lecture 10

Page 24: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Variance examples

I If X is number on a standard die roll, what is Var[X ]?

I Var[X ] = E [X 2]− E [X ]2 =1612 + 1

622 + 1632 + 1

642 + 1652 + 1

662 − (7/2)2 = 916 −

494 = 35

12 .

I Let Y be number of heads in two fair coin tosses. What isVar[Y ]?

I Recall P{Y = 0} = 1/4 and P{Y = 1} = 1/2 andP{Y = 2} = 1/4.

I Then Var[Y ] = E [Y 2]− E [Y ]2 = 1402 + 1

212 + 1422 − 12 = 1

2 .

18.440 Lecture 10

Page 25: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Variance examples

I If X is number on a standard die roll, what is Var[X ]?

I Var[X ] = E [X 2]− E [X ]2 =1612 + 1

622 + 1632 + 1

642 + 1652 + 1

662 − (7/2)2 = 916 −

494 = 35

12 .

I Let Y be number of heads in two fair coin tosses. What isVar[Y ]?

I Recall P{Y = 0} = 1/4 and P{Y = 1} = 1/2 andP{Y = 2} = 1/4.

I Then Var[Y ] = E [Y 2]− E [Y ]2 = 1402 + 1

212 + 1422 − 12 = 1

2 .

18.440 Lecture 10

Page 26: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Variance examples

I If X is number on a standard die roll, what is Var[X ]?

I Var[X ] = E [X 2]− E [X ]2 =1612 + 1

622 + 1632 + 1

642 + 1652 + 1

662 − (7/2)2 = 916 −

494 = 35

12 .

I Let Y be number of heads in two fair coin tosses. What isVar[Y ]?

I Recall P{Y = 0} = 1/4 and P{Y = 1} = 1/2 andP{Y = 2} = 1/4.

I Then Var[Y ] = E [Y 2]− E [Y ]2 = 1402 + 1

212 + 1422 − 12 = 1

2 .

18.440 Lecture 10

Page 27: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 28: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 29: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 30: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 31: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 32: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

More variance examples

I You buy a lottery ticket that gives you a one in a millionchance to win a million dollars.

I Let X be the amount you win. What’s the expectation of X?

I How about the variance?

I Variance is more sensitive than expectation to rare “outlier”events.

I At a particular party, there are four five-foot-tall people, fivesix-foot-tall people, and one seven-foot-tall person. You pickone of these people uniformly at random. What is theexpected height of the person you pick?

I Variance?

18.440 Lecture 10

Page 33: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 34: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 35: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Identity

I If Y = X + b, where b is constant, then does it follow thatVar[Y ] = Var[X ]?

I Yes.

I We showed earlier that E [aX ] = aE [X ]. We claim thatVar[aX ] = a2Var[X ].

I Proof: Var[aX ] = E [a2X 2]− E [aX ]2 = a2E [X 2]− a2E [X ]2 =a2Var[X ].

18.440 Lecture 10

Page 36: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Identity

I If Y = X + b, where b is constant, then does it follow thatVar[Y ] = Var[X ]?

I Yes.

I We showed earlier that E [aX ] = aE [X ]. We claim thatVar[aX ] = a2Var[X ].

I Proof: Var[aX ] = E [a2X 2]− E [aX ]2 = a2E [X 2]− a2E [X ]2 =a2Var[X ].

18.440 Lecture 10

Page 37: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Identity

I If Y = X + b, where b is constant, then does it follow thatVar[Y ] = Var[X ]?

I Yes.

I We showed earlier that E [aX ] = aE [X ]. We claim thatVar[aX ] = a2Var[X ].

I Proof: Var[aX ] = E [a2X 2]− E [aX ]2 = a2E [X 2]− a2E [X ]2 =a2Var[X ].

18.440 Lecture 10

Page 38: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Identity

I If Y = X + b, where b is constant, then does it follow thatVar[Y ] = Var[X ]?

I Yes.

I We showed earlier that E [aX ] = aE [X ]. We claim thatVar[aX ] = a2Var[X ].

I Proof: Var[aX ] = E [a2X 2]− E [aX ]2 = a2E [X 2]− a2E [X ]2 =a2Var[X ].

18.440 Lecture 10

Page 39: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Standard deviation

I Write SD[X ] =√Var[X ].

I Satisfies identity SD[aX ] = aSD[X ].

I Uses the same units as X itself.

I If we switch from feet to inches in our “height of randomlychosen person” example, then X , E [X ], and SD[X ] each getmultiplied by 12, but Var[X ] gets multiplied by 144.

18.440 Lecture 10

Page 40: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Standard deviation

I Write SD[X ] =√Var[X ].

I Satisfies identity SD[aX ] = aSD[X ].

I Uses the same units as X itself.

I If we switch from feet to inches in our “height of randomlychosen person” example, then X , E [X ], and SD[X ] each getmultiplied by 12, but Var[X ] gets multiplied by 144.

18.440 Lecture 10

Page 41: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Standard deviation

I Write SD[X ] =√Var[X ].

I Satisfies identity SD[aX ] = aSD[X ].

I Uses the same units as X itself.

I If we switch from feet to inches in our “height of randomlychosen person” example, then X , E [X ], and SD[X ] each getmultiplied by 12, but Var[X ] gets multiplied by 144.

18.440 Lecture 10

Page 42: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Standard deviation

I Write SD[X ] =√Var[X ].

I Satisfies identity SD[aX ] = aSD[X ].

I Uses the same units as X itself.

I If we switch from feet to inches in our “height of randomlychosen person” example, then X , E [X ], and SD[X ] each getmultiplied by 12, but Var[X ] gets multiplied by 144.

18.440 Lecture 10

Page 43: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 44: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Outline

Defining variance

Examples

Properties

Decomposition trick

18.440 Lecture 10

Page 45: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 46: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 47: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 48: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 49: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 50: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 51: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 52: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},

I and Var[A] =∑4

k=0 k2P{A = k} − E [A]2.

18.440 Lecture 10

Page 53: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Compute E [A] and Var[A].

I How many five card hands total?

I Answer:(525

).

I How many such hands have k aces?

I Answer:(4k

)( 485−k

).

I So P{A = k} =(4k)( 48

5−k)(525 )

.

I So E [A] =∑4

k=0 kP{A = k},I and Var[A] =

∑4k=0 k

2P{A = k} − E [A]2.

18.440 Lecture 10

Page 54: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 55: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 56: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 57: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 58: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 59: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 60: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 61: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Number of aces revisited

I Choose five cards from a standard deck of 52 cards. Let A bethe number of aces you see.

I Choose five cards in order, and let Ai be 1 if the ith cardchosen is an ace and zero otherwise.

I Then A =∑5

i=1 Ai . And E [A] =∑5

i=1 E [Ai ] = 5/13.

I Now A2 = (A1 + A2 + . . .+ A5)2 can be expanded into 25terms: A2 =

∑5i=1

∑5j=1 AiAj .

I So E [A2] =∑5

i=1

∑5j=1 E [AiAj ].

I Five terms of form E [AiAj ] with i = j five with i 6= j . Firstfive contribute 1/13 each. How about other twenty?

I E [AiAj ] = (1/13)(3/51) = (1/13)(1/17). SoE [A2] = 5

13 + 2013×17 = 105

13×17 .

I Var[A] = E [A2]− E [A]2 = 10513×17 −

2513×13 .

18.440 Lecture 10

Page 62: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 63: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 64: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 65: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 66: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 67: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 68: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10

Page 69: 18.440: Lecture 10 .1in Variance and standard deviationmath.mit.edu/~sheffield/440/Lecture10.pdf18.440: Lecture 10 Variance and standard deviation Scott She eld MIT 18.440 Lecture

Hat problem variance

I In the n-hat shuffle problem, let X be the number of peoplewho get their own hat. What is Var[X ]?

I We showed earlier that E [X ] = 1. So Var[X ] = E [X 2]− 1.

I But how do we compute E [X 2]?

I Decomposition trick: write variable as sum of simple variables.

I Let Xi be one if ith person gets own hat and zero otherwise.Then X = X1 + X2 + . . .+ Xn =

∑ni=1 Xi .

I We want to compute E [(X1 + X2 + . . .+ Xn)2].

I Expand this out and using linearity of expectation:

E [n∑

i=1

Xi

n∑j=1

Xj ] =n∑

i=1

n∑j=1

E [XiXj ] = n·1n

+n(n−1)1

n(n − 1)= 2.

I So Var[X ] = E [X 2]− (E [X ])2 = 2− 1 = 1.

18.440 Lecture 10