Probability – Distribution Function of 1/X When X is Uniform on [-1,1]

cumulative distribution functiondistributionsprobabilityuniform distribution

(from The Probability Tutoring Book, C. Ash, p. 157)

Find the density of $Y$ if $Y = 1/X$ and $X$ is uniform on $[-1,1]$.

The distribution function given in the answer key is

$$
F(y) =
\begin{cases}
\frac{-1}{2y} & \text{if }y \leq -1\\
\frac{1}{2} & \text{ if }-1 \leq y \leq 1\\
1-\frac{1}{2y} & \text{if } y \geq 1
\end{cases}
$$

My question is why the first and last cases aren't $0$ and $1$. Doesn't $Y$ only range over $[-1, 0)$ and $(0, 1]$?

Best Answer

I hope a quick simulation in R will help you visualize this transformation. For readable graphs, I use only transformed values in $(-10,10).$

set.seed(2020)
x = runif(10^5, -1,1)
y = 1/x
Y = y[abs(y) < 10]  # plotted values
length(y)
[1] 100000
length(Y)
[1] 89815
par(mfrow=c(1,2))
 hist(Y, prob=T, col="skyblue2")
 plot(ecdf(Y))
par(mfrow=c(1,1))

enter image description here

Note: The ECDF of a sample plots values of the sample from smallest to largest. It is a stairstep function (with jumps too small to see here). At each value of a sample of size $n$ the ECDF jumps up by $1/n.$ If there are $K$ values tied at a point, then the function jumps by $k/n$ at that point. (No ties here) For a sufficiently large sample the ECDF closely imitates the population CDF.