Undefined expectation for a random variable

probabilityprobability distributionsprobability theory

I am having a bit of trouble with the calculation of an expectation. Solving using the distribution function I get density $2$ but this "breaks" the expectation for $\frac{Z}{1-Z}$ and I get undefined. What am I doing wrong?

~

Let $X$ be random variable $\in U(0,1)$. Let $Z = min(X, 1-X)$. Find $EZ$ and $E(\frac{Z}{1-Z})$

Any help is greatly appreciated

Thanks in advance

Best Answer

My guess as to what you've done wrong is that the density of $Z$ isn't $$p_Z(z) = 2$$ but rather $$p_Z(z) = \begin{cases}2 & \text{if} \ 0 \le z \le 1/2 \\ 0 & \text{else} \end{cases}.$$ Hence, the expectations are $$\mathbb{E}[Z] = \int_{-\infty}^{\infty}zp_Z(z)\,dz = \int_{0}^{1/2}2z\,dz$$ and $$\mathbb{E}\left[\dfrac{Z}{1-Z}\right] = \int_{-\infty}^{\infty}\dfrac{z}{1-z}p_Z(z)\,dz = \int_{0}^{1/2}\dfrac{2z}{1-z}z\,dz,$$ both of which are well-defined and finite due to the bounds of the integral.