I am struggling with a probability question:
A point is chosen at random on a line segment of length 1. Let X be the ratio of the shorter to the longer segment.
a) Find $\mathbb E$(X)
b) Find P(X < $\frac{1}{4}$)
I was able to solve part b on my own but couldn't solve the first part
what I did in part a:
define probability density function $f$(x) by
$f(x) = \begin{cases} \frac{x}{1-x}, & \text{for $x$ < 0.5} \\ \frac{1-x}{x}, & \text{for $x$ > 0.5} \end{cases}$
then using
$\mathbb E$(X) = $\int_{-\infty}^\infty x f(x) dx$,
$\int_{0}^{0.5} \frac{x^2}{1-x} dx$ + $\int_{0.5}^{1}(1-x) dx = 0.1931$
but I get this as wrong answer. Am I approaching in a wrong way?
I appreciate any help.
Let $U$ be the uniform distribution that we use to pick the point.
$$X=\begin{cases} \frac{U}{1-U} &, U< 0.5 \\ \frac{1-U}{U} &, U \ge 0.5\end{cases}$$
\begin{align} E[X]&=E[X|U<0.5]P(U<0.5) + E[X|U>0.5]P(U>0.5)\\ &=\frac12\int_0^{0.5} \frac{2u}{1-u} \, du + \frac12\int_{0.5}^1\frac{2(1-u)}{u}\, du \\ &= \int_0^{0.5} \frac{u}{1-u}\, du + \int_{0.5}^1 \frac{1-u}{u} \, du\\ &= -\int_{1}^{0.5} \frac{1-v}{v}\, dv+ \int_{0.5}^1 \frac{1-u}{u} \, du\\ &= 2\int_{0.5}^1 u^{-1}-1\, du \\ &= 2(\ln u-u)|_{0.5}^1\\ &= 2(-1-\ln 0.5+0.5)\\ &= 2(\ln 2-\frac12) \\ &= 2\ln 2 -1 \end{align}
Remark: the $f$ that you stated is not a pdf.