= Solution
Integrating the two linear pieces gives the <cumulative distribution function>
$$
F(x)=\begin{cases}
0,&x<1,\\(x-1)^2/12,&1\le x\le3,\\1-(7-x)^2/24,&3\le x\le7,\\1,&x>7.
\end{cases}
$$
The split probability is $F(3)=1/3$. Invert each branch to obtain the <method of inversion>:
$$
\boxed{X=\begin{cases}1+\sqrt{12U},&0\le U\le1/3,\\7-\sqrt{24(1-U)},&1/3<U\le1.\end{cases}}
$$
Both expressions equal three at the split. For an ideal uniform draw, monotonicity gives $\mathbb P(F^{-1}(U)\le x)=\mathbb P(U\le F(x))=F(x)$, proving the target law. \b[Inversion is preferable here]: its quantile is explicit, it uses one uniform and one square root per output, and has no rejected draws. Rejection remains useful for densities with no convenient inverse CDF.
Back to article page