Solution (source code)

= Solution

Normalization of the <probability density function> gives
$$
1=A\int_0^{2\pi}(\pi-\phi/2)\,d\phi=A\pi^2,\qquad
\boxed{A=\pi^{-2}.}
$$
The first two <moments> are
$$
\mathbb E\Phi=\frac1{\pi^2}\int_0^{2\pi}\phi(\pi-\phi/2)\,d\phi=\frac{2\pi}{3},\qquad
\mathbb E\Phi^2=\frac1{\pi^2}\int_0^{2\pi}\phi^2(\pi-\phi/2)\,d\phi=\frac{2\pi^2}{3}.
$$
Consequently
$$
\boxed{\mathbb E\Phi=\frac{2\pi}{3},\qquad
\operatorname{Var}\Phi=\frac{2\pi^2}{3}-\frac{4\pi^2}{9}=\frac{2\pi^2}{9}.}
$$
The <cumulative distribution function> is $F(\phi)=\phi/\pi-\phi^2/(4\pi^2)=1-(1-\phi/(2\pi))^2$ on $[0,2\pi]$. For $U$ with the <uniform distribution> on $(0,1)$, <inverse transform sampling> therefore uses
$$
\boxed{\Phi=2\pi\left(1-\sqrt{1-U}\right).}
$$
The inverse lies in the required interval and satisfies $F(\Phi)=U$.