Correlation problem involving diagram Here's a difficulty I am facing to understand the solution of this problem.The first pic is the question and the second one is the solution given in the book.
I am not getting the process of getting the marginal density of $Y$.That is how will I find $h(y)$. 
Please help
More or less by definition, the marginal pdfs $f_X$ and $f_Y$ satisfy\begin{align*}
f_Y(y) = \int_{-\infty}^{\infty} \;f_Y(y|x)f_X(x)\, dx.
\end{align*}
(I'm calling this essentially a definition, but compare it to the discrete case or consider Fubini's theorem and related results.) Thus
\begin{align*}
h(y) 
  &amp;= \int_{-\infty}^{\infty} \;f_Y(y|x)g(x)\, dx = \int_{-\frac{1}{2}}^{\frac{1}{2}} \;f_Y(y|x)\, dx,
\end{align*}
and churning through the integral as indicated gives $h$.
The joint density $f(x,y)$ is uniform on a region that's symmetric about the $y$-axis:

$$\begin{align}f(x,y)&amp;=g(x)\,f_Y(y|x)\\
&amp;=[-\frac{1}{2}&lt;x&lt;\frac{1}{2}]\,\left([-\frac{1}{2}&lt;x&lt;0][x&lt;y&lt;x+1]+[0&lt;x&lt;\frac{1}{2}][-x&lt;y&lt;-x+1]\right)\\
&amp;=[-\frac{1}{2}&lt;x&lt;0][x&lt;y&lt;x+1]+[0&lt;x&lt;\frac{1}{2}][-x&lt;y&lt;-x+1]
\end{align}$$

using Iverson bracket notation. Thus $f(x,y)$ is everywhere either $0$ or $1$. Let $S$ denote the region in the $(x,y)$-plane where $f(x,y)=1$; i.e., $S$ is the shaded region in the posted diagram.

Then
$$h(y)=\int_\mathbb{R}f(x,y)\,dx= \int_{S_y} 1\,dx$$
where $S_y$ denotes the portion of $S$ intersected by a line parallel to the $x$-axis at a given $y$-coordinate.

To evaluate the integral explicitly, consider whether &amp; how a line parallel to the $x$-axis at a given $y$-value intersects $S$. Inspection shows that there are four regions to consider -- three regions where such a line intersects some part of $S$ and therefore contributes to the integral, and the remaining region where such a line misses $S$ and therefore does not contribute to the integral: 


If $\frac{1}{2}&lt;y&lt;1$, then such a line intersects $S$ giving a segment of $x$-values in an interval $y-1&lt;x&lt;1-y$, whose length is $(1-y)-(y-1)=2(1-y)$:
$$\int_{S_y}1\,dx = \int_{y-1}^{1-y}1\,dx= 2(1-y).$$
If $0&lt;y&lt;\frac{1}{2}$, then such a line intersects $S$ giving a segment of $x$-values in an interval $-\frac{1}{2}&lt;x&lt;\frac{1}{2}$, whose length is $\frac{1}{2}-(-\frac{1}{2})=1$.
$$\int_{S_y}1\,dx = \int_{-\frac{1}{2}}^{\frac{1}{2}}1\,dx= 1.$$  
If $-\frac{1}{2}&lt;y&lt;0$, then such a line intersects $S$ giving two segments of $x$-values, namely, the intervals $-\frac{1}{2}&lt;x&lt;y$ and $-y&lt;x&lt;\frac{1}{2}$, whose lengths are, respectively, $y-(-\frac{1}{2})=y+\frac{1}{2}$ and $\frac{1}{2}-(-y)=y+\frac{1}{2}$, for a total length of $1+2y$:
$$\int_{S_y}1\,dx = \int_{-\frac{1}{2}}^{y}1\,dx + \int_{-y}^{\frac{1}{2}}1\,dx= 1+2y.$$  
If $y&lt;-\frac{1}{2}$ or $y&gt;1$, then such a line does not intersect $S$:
$$\int_{S_y}1\,dx =0.$$




NB: Because $f$ is symmetric in $x$ (i.e., $f(-x,y)=f(x,y)$ for all $x,y$), the marginal density $h(y)$ is not needed to answer the questions in the exercise. If $\phi(x,y)$ is any function that's antisymmetric in $x$ (i.e., $\phi(-x,y)=-\phi(x,y)$ for all $x,y$, then 
$$\begin{align}E[\phi(X,Y)]&amp;=\int_\mathbb{R}\phi(x,y)f(x,y)\,dx\,dy\\
&amp;=\int_A \phi(x,y)f(x,y)\,dx\,dy +  \int_B \phi(x,y)f(x,y)\,dx\,dy\\ 
&amp;=\int_A \phi(x,y)f(x,y)\,dx\,dy +  \int_A \phi(-x,y)f(-x,y)\,dx\,dy\\
&amp;=\int_A \phi(x,y)f(x,y)\,dx\,dy -  \int_A \phi(x,y)f(x,y)\,dx\,dy\\
&amp;=0  
\end{align}$$
where $A$ and $B$ are the portions of $S$ to the right and left, respectively,  of the $y$-axis.

Thus, $E[XY]=0$ and $E[X] = 0$, so $X$ and $Y$ are uncorrelated (i.e., $E[XY]-E[X]\cdot E[Y]=0-0\cdot E[Y]=0$). 

NB: There's a typo in the book's answer, which should say that $X$ and $Y$ are not independent. Without having to find the marginal density $h$, this follows immediately from the fact that the support of $f$ (i.e., the set $S$) is not a Cartesian product. In order to have $f(x,y)=g(x)h(y)$ for all $x,y$, it's necessary that the support of $f$ be the Cartesian product of the supports of $g$ and $h$. If the latter are intervals (as they are here), then the former must be a rectangle, unlike the non-rectangular shape of $S$.