Tag Archives: Conditional Mean

Practice Problems for Conditional Distributions, Part 2

The following are practice problems on conditional distributions. The thought process of how to work with these practice problems can be found in the blog post Conditionals Distribution, Part 2.

_____________________________________________________________________________________

Practice Problems

Practice Problem 1

Suppose that X is the lifetime (in years) of a brand new machine of a certain type. The following is the density function.

    \displaystyle f(x)=\frac{1}{8 \sqrt{x}}, \ \ \ \ \ \ \ \ \ 1<x<25

You just purchase a 9-year old machine of this type that is in good working condition. Compute the following:

  • What is the expected lifetime of this 9-year old machine?
  • What is the expected remaining life of this 9-year old machine?

\text{ }

Practice Problem 2

Suppose that X is the total amount of damages (in millions of dollars) resulting from the occurrence of a severe wind storm in a certain city. The following is the density function of X.

    \displaystyle f(x)=\frac{81}{(x+3)^4}, \ \ \ \ \ \ \ \ \ 0<x<\infty

Suppose that the next storm is expected to cause damages exceeding one million dollars. Compute the following:

  • What is the expected total amount of damages for the next storm given that it will exceeds one million dollars?
  • The city has a reserve fund of one million dollars to cover the damages from the next storm. Given the amount of damages for the next storm will exceeds one million dollars, what is the expected total amount of damages in excess of the amount in the reserve fund?

_____________________________________________________________________________________

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }
_____________________________________________________________________________________

Answers

The thought process of how to work with these practice problems can be found in the blog post Conditionals Distribution, Part 2.

Practice Problem 1

    \displaystyle E(X \lvert X>9)=\frac{49}{3}=16.33 \text{ years}

    \displaystyle E(X-9 \lvert X>9)=\frac{22}{3}=7.33 \text{ years}

Practice Problem 2

    \displaystyle E(X \lvert X>1)=3 \text{ millions}

    \displaystyle E(X-1 \lvert X>1)=2 \text{ millions}

_____________________________________________________________________________________

\copyright \ 2013 \text{ by Dan Ma}

Advertisements

Practice Problems for Conditional Distributions, Part 1

The following are practice problems on conditional distributions. The thought process of how to work with these practice problems can be found in the blog post Conditionals Distribution, Part 1.

_____________________________________________________________________________________

Description of Problems

Suppose X and Y are independent binomial distributions with the following parameters.

    For X, number of trials n=5, success probability \displaystyle p=\frac{1}{2}

    For Y, number of trials n=5, success probability \displaystyle p=\frac{3}{4}

We can think of these random variables as the results of two students taking a multiple choice test with 5 questions. For example, let X be the number of correct answers for one student and Y be the number of correct answers for the other student. For the practice problems below, passing the test means having 3 or more correct answers.

Suppose we have some new information about the results of the test. The problems below are to derive the conditional distributions of X or Y based on the new information and to compare the conditional distributions with the unconditional distributions.

Practice Problem 1

  • New information: X<Y.
  • Derive the conditional distribution for X \lvert X<Y.
  • Derive the conditional distribution for Y \lvert X<Y.
  • Compare these conditional distributions with the unconditional ones with respect to mean and probability of passing.
  • What is the effect of the new information on the test performance of each of the students?
  • Explain why the new information has the effect on the test performance?

Practice Problem 2

  • New information: X>Y.
  • Derive the conditional distribution for X \lvert X>Y.
  • Derive the conditional distribution for Y \lvert X>Y.
  • Compare these conditional distributions with the unconditional ones with respect to mean and probability of passing.
  • What is the effect of the new information on the test performance of each of the students?
  • Explain why the new information has the effect on the test performance?

Practice Problem 3

  • New information: Y=X+1.
  • Derive the conditional distribution for X \lvert Y=X+1.
  • Derive the conditional distribution for Y \lvert Y=X+1.
  • Compare these conditional distributions with the unconditional ones with respect to mean and probability of passing.
  • What is the effect of the new information on the test performance of each of the students?
  • Explain why the new information has the effect on the test performance?

_____________________________________________________________________________________

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }

\text{ }
_____________________________________________________________________________________

Partial Answers

To let you know that you are on the right track, the conditional distributions are given below.

The thought process of how to work with these practice problems can be found in the blog post Conditional Distributions, Part 1.

Practice Problem 1

    \displaystyle P(X=0 \lvert X<Y)=\frac{1023}{22938}=0.0446

    \displaystyle P(X=1 \lvert X<Y)=\frac{5040}{22938}=0.2197

    \displaystyle P(X=2 \lvert X<Y)=\frac{9180}{22938}=0.4

    \displaystyle P(X=3 \lvert X<Y)=\frac{6480}{22938}=0.2825

    \displaystyle P(X=4 \lvert X<Y)=\frac{1215}{22938}=0.053

    ____________________

    \displaystyle P(Y=1 \lvert X<Y)=\frac{10}{22933}=0.0004

    \displaystyle P(Y=2 \lvert X<Y)=\frac{540}{22933}=0.0235

    \displaystyle P(Y=3 \lvert X<Y)=\frac{4320}{22933}=0.188

    \displaystyle P(Y=4 \lvert X<Y)=\frac{10530}{22933}=0.459

    \displaystyle P(Y=5 \lvert X<Y)=\frac{7533}{22933}=0.328

Practice Problem 2

    \displaystyle P(X=1 \lvert X>Y)=\frac{5}{3386}=0.0013

    \displaystyle P(X=2 \lvert X>Y)=\frac{160}{3386}=0.04

    \displaystyle P(X=3 \lvert X>Y)=\frac{1060}{3386}=0.2728

    \displaystyle P(X=4 \lvert X>Y)=\frac{1880}{3386}=0.4838

    \displaystyle P(X=5 \lvert X>Y)=\frac{781}{3386}=0.2

    ____________________

    \displaystyle P(Y=0 \lvert X>Y)=\frac{31}{3386}=0.008

    \displaystyle P(Y=1 \lvert X>Y)=\frac{390}{3386}=0.1

    \displaystyle P(Y=2 \lvert X>Y)=\frac{1440}{3386}=0.37

    \displaystyle P(Y=3 \lvert X>Y)=\frac{1620}{3386}=0.417

    \displaystyle P(Y=4 \lvert X>Y)=\frac{405}{3386}=0.104

Practice Problem 3

    \displaystyle P(X=0 \lvert Y=X+1)=\frac{15}{8430}=0.002

    \displaystyle P(X=1 \lvert Y=X+1)=\frac{450}{8430}=0.053

    \displaystyle P(X=2 \lvert Y=X+1)=\frac{2700}{8430}=0.32

    \displaystyle P(X=3 \lvert Y=X+1)=\frac{4050}{8430}=0.48

    \displaystyle P(X=4 \lvert Y=X+1)=\frac{1215}{8430}=0.144

    ____________________

    \displaystyle P(Y=1 \lvert Y=X+1)=\frac{15}{8430}=0.002

    \displaystyle P(Y=2 \lvert Y=X+1)=\frac{450}{8430}=0.053

    \displaystyle P(Y=3 \lvert Y=X+1)=\frac{2700}{8430}=0.32

    \displaystyle P(Y=4 \lvert Y=X+1)=\frac{4050}{8430}=0.48

    \displaystyle P(Y=5 \lvert Y=X+1)=\frac{1215}{8430}=0.144

_____________________________________________________________________________________

\copyright \ 2013 \text{ by Dan Ma}

Another Example on Calculating Covariance

In a previous post called An Example on Calculating Covariance, we calculated the covariance and correlation coefficient of a discrete joint distribution where the conditional mean E(Y \lvert X=x) is a linear function of x. In this post, we give examples in the continuous case. Problem A is worked out and Problem B is left as exercise.

The examples presented here are also found in the post called Another Example of a Joint Distribution. Some of the needed calculations are found in this previous post.

____________________________________________________________________

Problem A
Let X be a random variable with the density function f_X(x)=\alpha^2 \ x \ e^{-\alpha x} where x>0. For each realized value X=x, the conditional variable Y \lvert X=x is uniformly distributed over the interval (0,x), denoted symbolically by Y \lvert X=x \sim U(0,x). Obtain solutions for the following:

  1. Calculate the density function, the mean and the variance for the conditional variable Y \lvert X=x.
  2. Calculate the density function, the mean and the variance for the conditional variable X \lvert Y=y.
  3. Use the fact that the conditional mean E(Y \lvert X=x) is a linear function of x to calculate the covariance Cov(X,Y) and the correlation coefficient \rho.

Problem B
Let X be a random variable with the density function f_X(x)=4 \ x^3 where 0<x<1. For each realized value X=x, the conditional variable Y \lvert X=x is uniformly distributed over the interval (0,x), denoted symbolically by Y \lvert X=x \sim U(0,x). Obtain solutions for the following:

  1. Calculate the density function, the mean and the variance for the conditional variable Y \lvert X=x.
  2. Calculate the density function, the mean and the variance for the conditional variable X \lvert Y=y.
  3. Use the fact that the conditional mean E(Y \lvert X=x) is a linear function of x to calculate the covariance Cov(X,Y) and the correlation coefficient \rho.

____________________________________________________________________

Background Results

Here’s the idea behind the calculation of correlation coefficient in this post. Suppose X and Y are jointly distributed. When the conditional mean E(Y \lvert X=x) is a linear function of x, that is, E(Y \lvert X=x)=a+bx for some constants a and b, it can be written as the following:

    \displaystyle E(Y \lvert X=x)=\mu_Y + \rho \ \frac{\sigma_Y}{\sigma_X} \ (x - \mu_X)

Here, \mu_X=E(X) and \mu_Y=E(Y). The notations \sigma_X and \sigma_Y refer to the standard deviation of X and Y, respectively. Of course, \rho refers to the correlation coefficient in the joint distribution of X and Y and is defined by:

    \displaystyle \rho=\frac{Cov(X,Y)}{\sigma_X \ \sigma_Y}

where Cov(X,Y) is the covariance of X and Y and is defined by

    Cov(X,Y)=E[(X-\mu_X) \ (Y-\mu_Y)]

or equivalently by Cov(X,Y)=E(X,Y)-\mu_X \mu_Y.

Just to make it clear, in the joint distribution of X and Y, if the conditional mean E(X \lvert Y=y) is a linear function of y, then we have:

    \displaystyle E(X \lvert Y=y)=\mu_X + \rho \ \frac{\sigma_X}{\sigma_Y} \ (y - \mu_Y)

____________________________________________________________________

Discussion of Problem A

Problem A-1

Since for each x, Y \lvert X=x has the uniform distribution U(0,x), we have the following:

    \displaystyle f_{Y \lvert X=x}=\frac{1}{x} for x>0

    \displaystyle E(Y \lvert X=x)=\frac{x}{2}

    \displaystyle Var(Y \lvert X=x)=\frac{x^2}{12}

Problem A-2

In a previous post called Another Example of a Joint Distribution, the joint density function of X and Y is calculated to be: f_{X,Y}(x,y)=\alpha^2 \ e^{-\alpha x}. In the same post, the marginal density of Y is calculated to be: f_Y(y)=\alpha e^{-\alpha y} (exponentially distributed). Thus we have:

    \displaystyle \begin{aligned} f_{X \lvert Y=y}(x \lvert y)&=\frac{f_{X,Y}(x,y)}{f_Y(y)} \\&=\frac{\alpha^2 \ e^{-\alpha x}}{\alpha \ e^{-\alpha \ y}} \\&=\alpha \ e^{-\alpha \ (x-y)} \text{ where } y<x<\infty \end{aligned}

Thus the conditional variable X \lvert Y=y has an exponential distribution that is shifted to the right by the amount y. Thus we have:

    \displaystyle E(X \lvert Y=y)=\frac{1}{\alpha}+y

    \displaystyle Var(Y \lvert X=x)=\frac{1}{\alpha^2}

Problem A-3

To compute the covariance Cov(X,Y), one approach is to use the definition indicated above (to see this calculation, see Another Example of a Joint Distribution). Here we use the idea that the conditional mean \displaystyle E(Y \lvert X=x) is linear in x. From the previous post Another Example of a Joint Distribution, we have:

    \displaystyle \sigma_X=\frac{\sqrt{2}}{\alpha}

    \displaystyle \sigma_Y=\frac{1}{\alpha}

Plugging in \sigma_X and \sigma_Y, we have the following calculation:

    \displaystyle \rho \ \frac{\sigma_Y}{\sigma_X}=\frac{1}{2}

    \displaystyle \rho = \frac{\sigma_X}{\sigma_Y} \times \frac{1}{2}=\frac{\sqrt{2}}{2}=\frac{1}{\sqrt{2}}=0.7071

    \displaystyle Cov(X,Y)=\rho \ \sigma_X \ \sigma_Y=\frac{1}{\alpha^2}

____________________________________________________________________

Answers for Problem B

Problem B-1

    \displaystyle E(Y \lvert X=x)=\frac{x}{2}

    \displaystyle Var(Y \lvert X=x)=\frac{x^2}{12}

Problem B-2

    \displaystyle f_{X \lvert Y=y}(x \lvert y)=\frac{4 \ x^2}{1-y^3} where 0<y<1 and y<x<1

Problem B-3

    \displaystyle \rho=\frac{\sqrt{3}}{2 \ \sqrt{7}}=0.3273268

    \displaystyle Cov(X,Y)=\frac{1}{75}

____________________________________________________________________
\copyright \ 2013

An Example on Calculating Covariance

Probem 1
Let X be the value of one roll of a fair die. If the value of the die is x, we are given that Y \lvert X=x has a binomial distribution with n=x and p=\frac{1}{4} (we use the notation Y \lvert X=x \sim \text{binom}(x,\frac{1}{4})).

  1. Compute the mean and variance of X.
  2. Compute the mean and variance of Y.
  3. Compute the covariance Cov(X,Y) and the correlation coefficient \rho.

Probem 2
Let X be the value of one roll of a fair die. If the value of the die is x, we are given that Y \lvert X=x has a binomial distribution with n=x and p=\frac{1}{2} (we use the notation Y \lvert X=x \sim \text{binom}(x,\frac{1}{2})).

  1. Compute the mean and variance of X.
  2. Compute the mean and variance of Y.
  3. Compute the covariance Cov(X,Y) and the correlation coefficient \rho.

Problem 2 is left as exercise.

_________________________________________________________
Discussion of Problem 1

The joint variables X and Y are identical to the ones in this previous post. However, we do not plan on following the approach in the previous, which is to first find the probability functions for the joint distribution and then the marginal distribution of Y. The calculation of covariance in Problem 1.3 can be very tedious by taking this approach.

Problem 1.1
We start with the easiest part, which is the random variable X (the roll of the die). The variance is computed by Var(X)=E(X^2)-E(X)^2.

\displaystyle (1) \ \ \ \ \ E(X)=\frac{1}{6} \biggl[1+2+3+4+5+6 \biggr]=\frac{21}{6}=3.5

\displaystyle (2) \ \ \ \ \ E(X^2)=\frac{1}{6} \biggl[1^2+2^2+3^2+4^2+5^2+6^2 \biggr]=\frac{91}{6}

\displaystyle (3) \ \ \ \ \ Var(X)=\frac{91}{6}-\biggl[\frac{21}{6}\biggr]^2=\frac{105}{36}=\frac{35}{12}

Problem 1.2

We now compute the mean and variance of Y. The calculation of finding the joint distribution and then finding the marginal distribution of Y is tedious and has been done in this previous post. We do not take this approach here. Instead, we find the unconditional mean E(Y) by weighting the conditional mean E(Y \lvert X=x). The weights are the probabilities P(X=x). The following is the idea.

\displaystyle \begin{aligned}(4) \ \ \ \ \  E(Y)&=E_X[E(Y \lvert X=x)] \\&= E(Y \lvert X=1) \times P(X=1) \\&+ E(Y \lvert X=2) \times P(X=2)\\&+ E(Y \lvert X=3)  \times P(X=3) \\&+ E(Y \lvert X=4)  \times P(X=4) \\&+E(Y \lvert X=5)  \times P(X=5) \\&+E(Y \lvert X=6)  \times P(X=6) \end{aligned}

We have P(X=x)=\frac{1}{6} for each x. Before we do the weighting, we need to have some items about the conditional distribution Y \lvert X=x. Since Y \lvert X=x has a binomial distribution, we have:

\displaystyle (5) \ \ \ \ \ E(Y \lvert X=x)=\frac{1}{4} \ x

\displaystyle (6) \ \ \ \ \ Var(Y \lvert X=x)=\frac{1}{4} \ \frac{3}{4} \ x=\frac{3}{16} \ x

For any random variable W, Var(W)=E(W^2)-E(W)^2 and E(W^2)=Var(W)+E(W)^2. The following is the second moment of Y \lvert X=x, which is needed in calculating the unconditional variance Var(Y).

\displaystyle \begin{aligned}(7) \ \ \ \ \ E(Y^2 \lvert X=x)&=\frac{3}{16} \ x+\biggl[\frac{1}{4} \ x \biggr]^2 \\&=\frac{3x}{16}+\frac{x^2}{16} \\&=\frac{3x+x^2}{16}  \end{aligned}

We can now do the weighting to get the items of the variable Y.

\displaystyle \begin{aligned}(8) \ \ \ \ \  E(Y)&=\frac{1}{6} \biggl[\frac{1}{4} +\frac{2}{4}+\frac{3}{4}+ \frac{4}{4}+\frac{5}{4}+\frac{6}{4}\biggr] \\&=\frac{7}{8} \\&=0.875  \end{aligned}

\displaystyle \begin{aligned}(9) \ \ \ \ \  E(Y^2)&=\frac{1}{6} \biggl[\frac{3(1)+1^2}{16} +\frac{3(2)+2^2}{16}+\frac{3(3)+3^2}{16} \\&+ \frac{3(4)+4^2}{16}+\frac{3(5)+5^2}{16}+\frac{3(6)+6^2}{16}\biggr] \\&=\frac{154}{96} \\&=\frac{77}{48}  \end{aligned}

\displaystyle \begin{aligned}(10) \ \ \ \ \  Var(Y)&=E(Y^2)-E(Y)^2 \\&=\frac{77}{48}-\biggl[\frac{7}{8}\biggr]^2 \\&=\frac{161}{192} \\&=0.8385 \end{aligned}

Problem 1.3

The following is the definition of covariance of X and Y:

\displaystyle (11) \ \ \ \ \ Cov(X,Y)=E[(X-\mu_X)(Y-\mu_Y)]

where \mu_X=E(X) and \mu_Y=E(Y).

The definition (11) can be simplified as:

\displaystyle (12) \ \ \ \ \ Cov(X,Y)=E[XY]-E[X] E[Y]

To compute E[XY], we can use the joint probability function of X and Y to compute this expectation. But this is tedious. Anyone who wants to try can go to this previous post to obtain the joint distribution.

Note that the conditional mean E(Y \lvert X=x)=\frac{x}{4} is a linear function of x. It is a well known result in probability and statistics that whenever a conditional mean E(Y \lvert X=x) is a linear function of x, the conditional mean can be written as:

\displaystyle (13) \ \ \ \ \ E(Y \lvert X=x)=\mu_Y+\rho \ \frac{\sigma_Y}{\sigma_X} \ (x-\mu_X)

where \mu is the mean of the respective variable, \sigma is the standard deviation of the respective variable and \rho is the correlation coefficient. The following relates the correlation coefficient with the covariance.

\displaystyle (14) \ \ \ \ \ \rho=\frac{Cov(X,Y)}{\sigma_X \ \sigma_Y}

Comparing (5) and (13), we have \displaystyle \rho \frac{\sigma_Y}{\sigma_X}=\frac{1}{4} and

\displaystyle (15) \ \ \ \ \  \rho = \frac{\sigma_X}{4 \ \sigma_Y}

Equating (14) and (15), we have Cov(X,Y)=\frac{\sigma_X^2}{4}. Thus we deduce that Cov(X,Y) is one-fourth of the variance of X. Using (3), we have:

\displaystyle (16) \ \ \ \ \  Cov(X,Y) = \frac{1}{4} \times \frac{35}{12}=\frac{35}{48}=0.72917

Plug in all the items of (3), (10), and (16) into (14), we obtained \rho=0.46625. Both \rho and Cov(X,Y) are positive, an indication that both variables move together. When one increases, the other variable also increases. Thus makes sense based on the definition of the variables. For example, when the value of the die is large, the number of trials of Y is greater (hence a larger mean).