Symmetric rational mixture sampler (source code)

= Symmetric rational mixture sampler
{title2=$f_p(x)=\frac{p}{\pi(1+x^2)}+(1-p)\frac{|x|}{(1+x^2)^2}$}

The displayed <mixture distribution> combines a <Standard Cauchy distribution> and a symmetric law whose magnitude has <cumulative distribution function> $r^2/(1+r^2)$ for $r\geq0$. Use independent uniforms $U,V,H$: if $U\leq p$, return $\tan(\pi(V-1/2))$; otherwise return a fair independent sign times $\sqrt{V/(1-V)}$. The magnitude density is $2r/(1+r^2)^2$ and splitting its mass equally between signs gives $|x|/(1+x^2)^2$. An alternative <rejection sampling> proposal is standard Cauchy, with envelope constant $M=p+\pi(1-p)/2$, because $|x|/(1+x^2)\leq1/2$.