Let [mathjaxinline](X,Y)[/mathjaxinline] be a pair of random variables with joint density [mathjaxinline]h(x,y) = x+y[/mathjaxinline] over the space [mathjaxinline][0,1]^2[/mathjaxinline].

What is the marginal density of [mathjaxinline]X[/mathjaxinline]? We denote this by writing [mathjaxinline]h(x)[/mathjaxinline].

[mathjaxinline]h(x)=[/mathjaxinline]

What is the conditional density of [mathjaxinline]Y[/mathjaxinline] given [mathjaxinline]X=x[/mathjaxinline]? We denote this by writing [mathjaxinline]h(y|x)[/mathjaxinline].

[mathjaxinline]h(y|x)=[/mathjaxinline]

Consider the joint density setup as in the previous problem. What is the variance of Y given X=x?

\textsf{Var}(Y | X=x)=

To find the marginal density of X, we integrate the joint density over the range of Y:

[math]\begin{align*}
h(x) &= \int_{0}^{1} (x+y) dy \\
&= xy + \frac{1}{2}y^2 \Bigg|_{0}^{1} \\
&= x + \frac{1}{2}
\end{align*}[/math]

So the marginal density of X is [math]h(x) = x + \frac{1}{2}[/math].

To find the conditional density of Y given X=x, we divide the joint density by the marginal density of X:

[math]\begin{align*}
h(y|x) &= \frac{h(x, y)}{h(x)} \\
&= \frac{x+y}{x+\frac{1}{2}}
\end{align*}[/math]

To find the variance of Y given X=x, we use the formula for conditional variance:

[math]\begin{align*}
\text{Var}(Y|X=x) &= E\left[(Y-E(Y|X=x))^2|X=x\right] \\
&= E\left[(Y-E(Y|X=x))^2\right] \quad \text{(since }X=x\text{ is already given)} \\
&= E\left[Y^2 - 2YE(Y|X=x) + (E(Y|X=x))^2\right] \\
&= E(Y^2) - 2E(YE(Y|X=x)) + E(Y|x)^2 \\
&= E(Y^2) - 2\left(E(YE(Y))|X=x\right) + E(Y|x)^2 \quad \text{(using the law of iterated expectations)} \\
&= E(Y^2) - 2\left(E(YE(Y))\right) + E(Y|x)^2 \quad \text{(since }X=x\text{ is constant)} \\
&= E(Y^2) - 2E(Y^2) + E(Y|x)^2 \quad \text{(since }Y\text{ and }E(Y)\text{ are independent given }X) \\
&= - E(Y^2) + E(Y|x)^2 \\
\end{align*}[/math]

Now we need to find [math]E(Y^2)[/math]:

[math]\begin{align*}
E(Y^2) &= \int_{0}^{1} y^2 h(y|x) dy \\
&= \int_{0}^{1} y^2 \frac{x+y}{x+\frac{1}{2}} dy \\
&= \frac{x^2+2x+\frac{5}{6}}{3x+1}
\end{align*}[/math]

Finally, substituting this into the formula for the variance, we have:

[math]\begin{align*}
\text{Var}(Y|X=x) &= - E(Y^2) + E(Y|x)^2 \\
&= -\frac{x^2+2x+\frac{5}{6}}{3x+1} + \left(\frac{x+1}{2}\right)^2 \\
&= -\frac{x^2+2x+\frac{5}{6}}{3x+1} + \frac{x^2+2x+1}{4} \\
&= -\frac{4x^2+8x+\frac{5}{6}}{12x+4} + \frac{3x^2+6x+3}{12} \\
&= -\frac{4x^2+8x+\frac{5}{6}}{12x+4} + \frac{3x^2+6x+3}{12} \\
&= \frac{9x^2+18x+9-4x^2-8x-\frac{5}{6}}{12} \\
&= \frac{5x^2+10x+\frac{49}{6}}{12}
\end{align*}[/math]

So the variance of Y given X=x is [math]\frac{5x^2+10x+\frac{49}{6}}{12}[/math].

To find the marginal density of [mathjaxinline]X[/mathjaxinline], we need to integrate the joint density [mathjaxinline]h(x,y) = x+y[/mathjaxinline] over the range of possible values of [mathjaxinline]Y[/mathjaxinline]. This can be written as:

[mathjax]
h(x) = \int_{-\infty}^{\infty} h(x,y) \, dy
= \int_{0}^{1} (x+y) \, dy
[/mathjax]

Simplifying the integral:

[mathjax]
h(x) = \int_{0}^{1} x \, dy + \int_{0}^{1} y \, dy
= x \int_{0}^{1} 1 \, dy + \int_{0}^{1} y \, dy
= x \cdot (y\big|_{0}^{1}) + \left(\frac{1}{2}y^2\big|_{0}^{1}\right)
= x + \frac{1}{2}
[/mathjax]

Therefore, the marginal density of [mathjaxinline]X[/mathjaxinline] is [mathjaxinline]h(x) = x + \frac{1}{2}[/mathjaxinline].

Now let's find the conditional density of [mathjaxinline]Y[/mathjaxinline] given [mathjaxinline]X=x[/mathjaxinline]. This can be calculated using Bayes' theorem:

[mathjax]
h(y|x) = \frac{h(x,y)}{h(x)}
[/mathjax]

Substituting the given joint density and marginal density:

[mathjax]
h(y|x) = \frac{x+y}{x + \frac{1}{2}}
[/mathjax]

Finally, to find the variance of [mathjaxinline]Y[/mathjaxinline] given [mathjaxinline]X=x[/mathjaxinline], we can use the definition of conditional variance:

[mathjax]
\text{Var}(Y | X=x) = \int_{-\infty}^{\infty} (y-\text{E}(Y|X=x))^2 h(y|x) \, dy
[/mathjax]

Since the conditional mean [mathjaxinline]\text{E}(Y|X=x)[/mathjaxinline] is equal to [mathjaxinline]x[/mathjaxinline] (as [mathjaxinline]X[/mathjaxinline] is given to be equal to [mathjaxinline]x[/mathjaxinline]), we have:

[mathjax]
\text{Var}(Y | X=x) = \int_{-\infty}^{\infty} (y-x)^2 h(y|x) \, dy
= \int_{0}^{1} (y-x)^2 \frac{x+y}{x + \frac{1}{2}} \, dy
[/mathjax]

Simplifying the integral:

[mathjax]
\text{Var}(Y | X=x) = \frac{x}{x+\frac{1}{2}} \cdot \int_{0}^{1} (y-x)^2 \, dy + \frac{1}{x+\frac{1}{2}} \cdot \int_{0}^{1} (y-x)^2 y \, dy
[/mathjax]

Evaluating the integrals:

[mathjax]
\int_{0}^{1} (y-x)^2 \, dy = \frac{1}{3} - x + x^2
\]

[mathjax]
\int_{0}^{1} (y-x)^2 y \, dy = \frac{1}{12} - x^2 + x^3
[/mathjax]

Substituting the integrals back into the expression:

[mathjax]
\text{Var}(Y | X=x) = \frac{x}{x+\frac{1}{2}} \left(\frac{1}{3} - x + x^2\right) + \frac{1}{x+\frac{1}{2}} \left(\frac{1}{12} - x^2 + x^3\right)
[/mathjax]

Therefore, the variance of [mathjaxinline]Y[/mathjaxinline] given [mathjaxinline]X=x[/mathjaxinline] is [mathjaxinline]\text{Var}(Y | X=x) = \frac{x}{x+\frac{1}{2}} \left(\frac{1}{3} - x + x^2\right) + \frac{1}{x+\frac{1}{2}} \left(\frac{1}{12} - x^2 + x^3\right)[/mathjaxinline].