expectation class6 prep a

Upload: abcd2003959

Post on 02-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Expectation Class6 Prep A

    1/7

    Expectation, Variance and Standard Deviation for

    Continuous Random Variables

    Class 6, 18.05, Spring 2014

    1 Learning Goals

    1. Be able to compute and interpret expectation, variance, and standard deviation forcontinuous random variables.

    2. Be able to compute and interpret quantiles for discrete and continuous random variables.

    2 Introduction

    So far we have looked at expected value, standard deviation, and variance for discreterandom variables. These summary statistics have the same meaning for continuous randomvariables:

    The expected value = E(X) is a measure of location or central tendency. The standard deviation is a measure of the spread or scale. The variance 2 = Var(X) is the square of the standard deviation.

    To move from discrete to continuous, we will simply replace the sums in the formulas byintegrals. We will do this carefully and go through many examples in the following sections.In the last section, we will introduce another type of summary statistic,quantiles. You mayalready be familiar with the .5 quantile of a distribution, otherwise known as the medianor 50th percentile.

    3 Expected value of a continuous random variable

    Definition: Let Xbe a continuous random variable with range [a, b] and probabilitydensity function f(x). The expected valueofXis defined by

    E(X) =

    ba

    xf(x) dx.

    Lets see how this compares with the formula for a discrete random variable:

    E(X) =

    ni=1

    xip(xi).

    The discrete formula says to take a weighted sum of the values xiofX, where the weights arethe probabilitiesp(xi). Recall that f(x) is a probabilitydensity. Its units are prob/(unit ofX).Sof(x) dxrepresents the probability thatXis in an infinitesimal range of width dx aroundx. Thus we can interpret the formula for E(X) as a weighted integral of the values x ofX,where the weights are the probabilities f(x) dx.

    As before, the expected value is also called the mean or average.

    1

  • 8/10/2019 Expectation Class6 Prep A

    2/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 2

    3.1 Examples

    Lets go through several example computations. Where the solution requires an integrationtechnique, we push the computation of the integral to the appendix.

    Example 1. LetX uniform(0, 1). Find E(X).answer:Xhas range [0, 1] and density f(x) = 1. Therefore,

    E(X) =

    10

    x dx= x2

    2

    1

    0

    = 1

    2 .

    Not surprisingly the mean is at the midpoint of the range.

    Example 2. LetXhave range [0, 2] and density 38x2. Find E(X).

    answer:

    E(X) =

    20

    xf(x) dx =

    20

    3

    8x3 dx =

    3x4

    32

    2

    0

    = 3

    2 .

    Does it make sense that this mean is in the right half of the range?

    answer: Yes. Since the probability density increases as x increases over the range, theaverage value ofxshould be in the right half of the range.

    x

    f(x)

    1 = 1.5

    is pulled to the right of the midpoint 1 because there is more mass to the right.

    Example 3. LetX exp(). Find E(X).answer:The range ofX is [0,) and its pdf is f(x) =ex. So (details in appendix)

    E(X) =

    0ex dx = ex e

    x

    0

    = 1

    .

    x

    f(x) = ex

    = 1/

    Mean of an exponential random variable

    Example 4. LetZ Norm(0, 1). Find E(Z).

    answer: The range of Z is (,) and its pdf is (z) = 12

    ez2/2. So (details in

    appendix)

    E(Z) =

    12

    zez2/2 dz = 1

    2ez

    2/2

    = 0.

  • 8/10/2019 Expectation Class6 Prep A

    3/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 3

    z

    (z)

    = 0

    The standard normal distribution is symmetric and has mean 0.

    3.2 Properties ofE(X)

    The properties ofE(X) for continuous random variables are the same as for discrete ones:

    1. IfXand Yare random variables on a sample space then

    E(X+ Y) =E(X) + E(Y)

    2. Ifa and b are constants then E(aX+ b) =aE(X) + b.

    Example 5. In this example we verify that for X

    Norm(, ) we have E(X) =.

    answer:Example (4) showed that for standard normal Z, E(Z) = 0. We could mimic thecalculation there to show E(X) = . Instead we will use the properties ofE(X). In theclass 5 notes on manipulating random variables we showed that for normalX

    Z=X

    Norm(0, 1).

    Inverting this formula we have X= Z+ . The linearity of expected value now gives

    E(X) =E( Z+ ) = E(Z) + =

    3.3 Expectation of Functions ofX

    This works exactly the same as the discrete case. ifh(x) is a function then Y =h(X) is arandom variable and

    E(Y) =E(h(X)) =

    h(x)fX(x) dx.

    Example 6. LetX exp(). Find E(X2).answer:Using integration by parts we have

    E(X2) =

    0x2ex dx=

    x2ex 2x

    ex 2

    2ex

    0

    = 2

    2 .

    4 Variance

    Now that weve defined expectation for continuous random variables, the definition of vari-ance is identical to that of discrete random variables.

    Definition: LetXbe a continuous random variable with mean . The variance ofX is

    Var(X) =E((X )2).

  • 8/10/2019 Expectation Class6 Prep A

    4/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 4

    4.1 Properties of Variance

    These are exactly the same as in the discrete case.

    1. IfXand Y are independent then Var(X+ Y) = Var(X) + Var(Y).

    2. For constants aand b, Var(aX+ b) =a2Var(X).

    3. Theorem: Var(X) =E(X2) E(X)2 =E(X2) 2.For Property 1, note carefully the requirement that X and Y are independent.

    Property 3 gives a formula for Var(X) that is often easier to use in hand calculations. Theproofs of properties 2 and 3 are essentially identical to those in the discrete case. We willnot give them here.

    Example 7. LetX uniform(0, 1). Find Var(X) and X.answer:In Example 1 we found = 1/2. Next we compute

    Var(X) =E((X

    )2) =

    1

    0

    (x

    1/2)2 dx=

    1

    12

    .

    Example 8. LetX exp(). Find Var(X) and X.answer:In Examples 3 and 6 we computed

    E(X) =

    0xex dx=

    1

    and E(X2) =

    0x2ex dx=

    2

    2.

    So by Property 3,

    Var(X) =E(X2) E(X)2 = 22 1

    2 =

    1

    2 and X=

    1

    .

    We could have skipped Property 3 and computed this directly from Var(X) =0 (x 1/)

    2

    ex

    dx.

    Example 9. LetZ Norm(0, 1). Show Var(Z) = 1.Note: The notation for normal variables is X Norm(, 2). This is certainly suggestive,but as mathematicians we need to prove that E(X) = and Var(X) = 2. Above weshowed E(X) =. This example shows that Var(Z) = 1, just as the notation suggests. Inthe next example well show Var(X) =2.

    answer:Since E(Z) = 0, we have

    Var(Z) =E(Z2) = 1

    2

    z2ez2/2 dz.

    (using integration by parts with u = z, v =zez2/2 u = 1, v= ez2/2)

    = 1

    2

    zez2/2

    +

    12

    ez2/2 dz.

    The first term equals 0 because the exponential goes to zero much faster than z grows atboth. The second term equals 1 because it represents the total probability integral ofthe pdf(z) for Norm(0, 1). So Var(X) = 1.

  • 8/10/2019 Expectation Class6 Prep A

    5/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 5

    Example 10. LetX Norm(, 2). Show Var(X) =2.answer:This is an exercise in change of variables. Letting z = (x )/, we have

    Var(X) =E((X )2) = 12

    (x )2e(x)2/22 dx

    = 22

    z2ez2/2 dz= 2.

    The integral in the last line is the same one we computed for Var(Z).

    5 Quantiles

    Definition: The median ofX is the value x for which P(X x) =P(X x). In otherwords, Xhas equal probability of being above or below the median, and each probabilityis therefore 1/2. Since the definition of the cdf is F(x) = P(X x), we can equivalentlydefine the median as the value x satisfyingF(x) =.5. i.e. F(x) =P(X

    x) =.5.

    Think: What is the median ofZ?

    answer:By symmetry, the median is 0.

    Example 11. Find the median ofX exp().answer:The cdf ofXis F(x) = 1ex. SoF(x) =.5 .5 = 1ex x = (ln2)/ .Think: In this case the median does not equal the mean of = 1/. Based on the graphof the pdf ofXcan you argue why the median is to the left of the mean.

    Definition: The pth quantileofX is the value qp such the F(qp) =P(X qp) =p. Inparticular, in this notation the median is q.5.

    With respect to the pdff(x), the quantile qp is the value such that there is an area ofp tothe left ofqp and an area of 1 p to the right ofqp. In the examples below, note how wecan represent the quantile graphically using area of the pdf or height of the cdf.

    Example 12. Find the .6 quantile for X U(0, 1).answer:The cdf for X is F(x) =x on the range [0,1]. So q.6 = .6.

    x

    f(x)

    q.6= .6

    left tail area = prob = .6

    x

    F(x)

    q.6= .6

    F(q.6) = .6

    1

    q.6: left tail area = .6 F(q.6) =.6Example 13. Find the .6 quantile of the standard normal distribution.

  • 8/10/2019 Expectation Class6 Prep A

    6/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 6

    answer:We dont have a formula for the cdf, so we use the R quantile function qnorm.

    q.6= qnorm(.6, 0, 1)= .25335

    z

    (z)

    q.6= .253

    Area = prob. = .6

    z

    (z)

    q.6= .253

    F(q.6) = .6

    1

    q.6: left tail area = .6 F(q.6) =.6

    Quantiles give a useful measure of locationfor a random variable. We will use them morein coming lectures.

    5.1 Percentiles, deciles, quartiles

    For convenience, quantiles are often described in terms of percentiles, deciles or quartiles.The 60th percentileis the same as the .6 quantile. For example you are in the 60th percentilefor height if you are taller than 60 percent of the population, i.e. the probabilitythat youare taller than a randomly chosen person is 60 percent.

    Likewise, decilesrepresent steps of 1/10. The third decile is the .3 quantile. Quartiles arein steps of 1/4. The third quartile is the .75 quantile and the 75th percentile.

    6 Appendix: Integral Computation Details

    Example 3: LetX exp(). Find E(X).The range ofX is [0,) and its pdf is f(x) =ex. Therefore

    E(X) =

    0xf(x) dx=

    0xex dx

    (using integration by parts with u = x,v =ex u = 1, v= ex)

    =xex0

    +

    0ex dx

    = 0ex

    0=

    1

    .

    We used the fact that xex and ex go to 0 as x .

    Example 4: LetZ Norm(0, 1). Find E(Z).

    The range ofZ is (,) and its pdf is (z) = 12

    ez2/2. By symmetry the mean must

    be 0. The only mathematically tricky part is to show that the integral converges, i.e. that

  • 8/10/2019 Expectation Class6 Prep A

    7/7

    18.05 class 6, Expectation and Variance for Continuous Random Variables 7

    the mean exists at all (some random variable do not have means, but we will not encounterthis very often.) For completeness we include the argument, though this is not somethingwe will ask you to do. We first compute the integral from 0 to :

    0z(z) dz=

    12

    0zez

    2/2 dz.

    The u-substitution u= z2/2 gives du= z dz. So the integral becomes

    12

    0zez

    2/2 dz. = 1

    2

    0eu du = eu

    0

    = 1

    Similarly,

    0

    z(z) dz= 1. Adding the two pieces together gives E(Z) = 0.

    Example 6: LetX exp(). Find E(X2).

    E(X2) =

    0

    x2f(x) dx=

    0

    x2ex dx

    (using integration by parts with u = x2,v =ex u = 2x, v = ex)

    =x2ex0

    +

    02xex dx

    (the first term is 0, for the second term use integration by parts: u = 2x, v = ex u = 2, v = ex )

    =

    2xex

    0

    +

    0

    ex

    dx

    = 0 2 ex

    2

    0

    = 2

    2.