# Show that $X$ and $Y$ are not independent

This question is taken from Rice - Mathematical statistics.

Let $Y$ have a density that is symmetric about zero, and let $X = SY$, where $S$ is an independent random variable taking on the values $+1$ and $−1$ with probability $1/2$ each. Show that $X$ and $Y$ are not independent.

I found an answer but I don't understand how the joint density function of X and Y is derived. Joint density function of $X$ any $Y$

$$f(x,y) =\begin{cases}\dfrac12f(y), & \text{ if } x = y\\ \dfrac12 f(-y), & \text{ if } x = -y\\ 0, & \text{ otherwise } \end{cases}$$

Observe that $$X=SY=\begin{cases}\phantom{-}Y, & \text{ if } S=1\\-Y, & \text{ if } S=-1 \end{cases}$$ Hence, given that $Y=y$, $X$ can take only the values $+y$ and $-y$ with positive probability. Hence, \begin{align}f(x,y)&=f(x\mid y)f(y)=P(X=x\mid Y=y)f(y)\\[0.3cm]&=P(SY=x\mid Y=y)f(y)=P(Sy=x)f(y)\\[0.3cm]&=\begin{cases}P(S=1)f(y), &\text{ if }x=y\\P(S=-1)f(y),& \text{ if }x=-y,\\ 0, & \text{ otherwise}\end{cases}\end{align} Now, since $f$ is symmetric about zero you have $f(y)=f(-y)$ which gives the result.