In an earlier post called An Example of a Joint Distribution, we worked a problem involving a joint distribution that is constructed from taking product of a conditional distribution and a marginial distribution (both discrete distributions). In this post, we work on similar problems for the continuous case. We work problem A. Problem B is left as exercises.
_________________________________________________________________
Problem A
Let be a random variable with the density function where . For each realized value , the conditional variable is uniformly distributed over the interval , denoted symbolically by . Obtain solutions for the following:
 Discuss the joint density function for and .
 Calculate the marginal distribution of , in particular the mean and variance.
 Calculate the marginal distribution of , in particular, the density function, mean and variance.
 Use the joint density in part A1 to calculate the covariance and the correlation coefficient .
_________________________________________________________________
Problem B
Let be a random variable with the density function where . For each realized value , the conditional variable is uniformly distributed over the interval , denoted symbolically by . Obtain solutions for the following:
 Discuss the joint density function for and .
 Calculate the marginal distribution of , in particular the mean and variance.
 Calculate the marginal distribution of , in particular, the density function, mean and variance.
 Use the joint density in part B1 to calculate the covariance and the correlation coefficient .
_________________________________________________________________
Discussion of Problem A
Problem A1
The support of the joint density function is the unbounded lower triangle in the xyplane (see the shaded region in green in the figure below).
Figure 1
The unbounded green region consists of vertical lines: for each , ranges from to (the red vertical line in the figure below is one such line).
Figure 2
For each point in each vertical line, we assign a density value which is a positive number. Taken together these density values sum to 1.0 and describe the behavior of the variables and across the green region. If a realized value of is , then the conditional density function of is:
Thus we have . In our problem at hand, the joint density function is:
As indicated above, the support of is the region and (the region shaded green in the above figures).
Problem A2
The unconditional density function of is (given above in the problem) is the density function of the sum of two independent exponential variables with the common density (see this blog post for the derivation using convolution method). Since is the independent sum of two identical exponential distributions, the mean and variance of is twice that of the same item of the exponential distribution. We have:
Problem A3
To find the marginal density of , for each applicable , we need to sum out the . According to the following figure, for each , we sum out all values in a horizontal line such that (see the blue horizontal line).
Figure 3
Thus we have:
Thus the marginal distribution of is an exponential distribution. The mean and variance of are:
Problem A4
The covariance of and is defined as , which is equivalent to:
where and . Knowing the joint density , we can calculate directly. We have:
Note that the last integrand in the last integral in the above derivation is that of a Gamma distribution (hence the integral is 1.0). Now the covariance of and is:
The following is the calculation of the correlation coefficient:
Even without the calculation of , we know that and are positively and quite strongly correlated. The conditional distribution of is which increases with . The calculation of and confirms our observation.
_________________________________________________________________
Answers for Problem B
Problem B1

where , and .
Problem B2
Problem B3
Problem B4
_________________________________________________________________