I programmed the "inverse transform sampling" according to its wikipage. It sounds amazing: Given a PDF: $$ p(x) $$ we can generate the samples by $$ s= F^{-1}(r) $$ where $r\in (0,1)$ is a uniform distribution and F(x) denotes the CDF of p(x).
I understand what PDF and CDF are, but I cannot see why the inverse of CDF generates the samples of PDF. Could someone explain it to me?
If I shot a vertical ray to a steep segment of the CDF, and then make a vertical line to x-axis, the value $p(x_0)$ should has a high value. This makes sense because the steep segment is easy to get horizontal shots.