Find the distribution of X, EX, and VarX. Suppose that the random variable $X$ is uniformly distributed symmetrically around zero, but in such a way that the parameter is uniform on $(0,1)$; that is, suppose that $$X\mid A=a\in U(-a,a) \text{ with } A\in U(0,1).$$ Find the distribution of $X$, $EX$, and $\operatorname{Var}X$. 
The answers in the book are $f_X(x)=-\frac{1}{2} \log|x|, \; -1<x<1; \; EX=0, \text{ and } \operatorname{Var}X=\frac{1}{9}$.
Any help on how to work this type of problem would be greatly appreciated.
 A: Let $Y\sim U([0,1])$ and $X|Y=y\sim U([-y,y])$
We know that by definition: $f(x,y)=f_{Y}(y)\cdot f_{X|Y}(x|y)$.
Since $Y\sim U([0,1])$ we have it that $f_{Y}(y)=1$ when $y\in[0,1]$
and is zero otherwise. thus $f(x,y)=0$ when $y\not\in[0,1]$ and
is $f_{X|Y}(x|y)$ otherwise.
We are also given that $X|Y=y\sim U([-y,y])$ hence $f_{X|Y}(x|y)=\frac{1}{y-(-y)}=\frac{1}{2y}$
when $x\in[-y,y]$ and is zero otherwise.
We conclude 
$$
f(x,y)=\begin{cases}
\frac{1}{2y} & y\in[0,1],x\in[-y,y]\\
0 & \text{otherwise}
\end{cases}
$$
Note that $x\in[-y,y]$ means $-y\leq x\leq y$, and thus $y\geq x$,
it is also clear that $y\leq1$
Also, $x\geq-y$ means $y\geq-x$ and since also $y\geq x$ we get
$y\geq|x|$
Now that we have the joint density we can get $f_{X}(x)$ by integrating:
$$
f_{X}(x)=\int_{-\infty}^{\infty}f(x,y)\, dy=\int_{|x|}^{1}\frac{1}{2y}\, dy=\frac{1}{2}(\log(y)|_{|x|}^{1})=\frac{1}{2}(\log(1)-\log(|x|))=-\frac{1}{2}\log|x|
$$
Now, $EX=EE[X|Y]$. $X|Y\sim U([-y,y])$ hence $E[X|Y|]=\frac{y+(-y)}{2}=0$.
Thus $EX=E[0]=0$.
Now we can calculate $Var(X)$: 
$$
Var(X)=EX^{2}-(EX)^{2}=EX^{2}
$$
Since $x\in[-y,y]$ and $y\in[0,1]$ we have it that $x\in[-1,1]$.
$$
EX^{2}=\int_{-\infty}^{\infty}x^{2}f_{X}(x)\, dx
$$
$$
=\int_{-1}^{1}x^{2}\cdot-\frac{1}{2}\log(|x|)\, dx
$$
$$
=-\frac{1}{2}\int_{-1}^{1}x^{2}\log(|x|)\, dx
$$
Using integration by parts with $u=\log(|x|),v'=x^{2}$we get 
$$
\int x^{2}\log(|x|)\, dx=\log(|x|)\cdot\frac{x^{3}}{3}-\int\frac{1}{x}\cdot\frac{x^{3}}{3}=\log(|x|)\cdot\frac{x^{3}}{3}-\frac{1}{3}\cdot\frac{x^{3}}{3}=\frac{x^{3}}{3}(\log(|x|)-\frac{1}{3})
$$
Hence 
$$
-\frac{1}{2}\int_{-1}^{1}x^{2}\log(|x|)\, dx
$$
$$
=-\frac{1}{2}(\frac{x^{3}}{3}(\log(|x|)-\frac{1}{3})|_{-1}^{1})
$$
$$
=-\frac{1}{2}(\frac{1^{3}}{3}(\log(|1|)-\frac{1}{3})-\frac{(-1)^{3}}{3}(\log(|-1|)-\frac{1}{3}))
$$
$$
=-\frac{1}{2}(-\frac{1}{3\cdot3}-\frac{1}{3\cdot3})=\frac{1}{9}
$$
A: The conditional variance given $A=a$ is the variance of the uniform distribution on the interval $(-a,a)$, so that is $(2a)^2/12$.  The conditional expected value given $A=a$ is $0$, by symmetry.
Since the conditional expected value given $A$ does not even depend on $A$, the law of total expectation says that is also the marginal (or "unconditional") expected value.
The law of total variance says
$$
\operatorname{Var}(X) = E(\operatorname{Var}(X\mid A)) + \operatorname{Var}(E(X\mid A)).
$$
The second term on the right is $\operatorname{Var}(0)$, so that is $0$.  The first term is
$$
E\left(\frac{(2A)^2}{12}\right) = \frac13 E(A^2) = \frac13\int_0^1 a^2 \, da = \frac13\cdot\frac13.
$$
The law of total probability can be used to find the cumulative probability distribution function:
$$
F_X(x) = \Pr(X\le x)= E(\Pr(X\le x\mid A)) = E\left(\begin{cases} \frac{x+A}{2A} & \text{if }-A\le x\le A \\[8pt] 0 & \text{if } x<-A \\[8pt] 1 & \text{if }x>A \end{cases} \right).$$
If $x>0$, this becomes
$$
\int_0^x 1\,da + \int_x^1 \frac{x+a}{2a}\,da =  x + \int_x^1 \frac{x}{2a} + \frac12\,da
$$
$$
= x + \frac x2 \left[ \log a  \right]_{a=x}^1 + \frac12 = x-\frac x2(\log x) + \frac12(1-x).
$$
Differentiate to get the density function: $f_X(x)$.
Do a similar thing if $x<0$.
