Mapping a wrapped Cauchy distribution to a uniform distribution? I'm investigating model mismatch and have a wrapped Cauchy distribution of
f(x,p) = (1-p^2)/ (2*pi*(1+p^2-2p*cos(x)))

Is there a way to map this to a random uniform distribution, like
random.uniform(100, minval=-q, maxval=q)

i.e. If I have a value of q, what p does that equate to? Thanks

Edit:
I have decided to match the moments to map the parameter. The means would be 0, but the variance would give:
$\frac{1}{12} (q--q)^2 = 1- e^\gamma$
Using the substitution for $\gamma$ to get to $p$, and rearranging, I get:
$p = \sqrt{\frac{1 - \tanh (-log(1-q^2/3))}{1 + \tanh (-log(1-q^2/3))}}$
but this does not behave as expected. i.e. when $p$ is close to 1, the distribution should be tight and therefore I would expect $q \rightarrow 0$ and when $p \rightarrow 0$, $q$ should be high, but this is not what happens - does anyone spot a mistake?
 A: Since the wrapped Cauchy distribution is made of the superposition of truncated scaled Cauchy distributions$^1$ translated by $2n\pi$ for all $n$'s $(n\in\mathbb Z)$:
$$f_{WC}(\theta;\gamma)=\sum_{n=-\infty}^\infty \frac{\gamma}{\pi(\gamma^2+(\theta+2\pi n)^2)}\,\mathbb I_{(-\pi,\pi)}(\theta)\qquad \gamma>0$$
it can be simulated by

*

*Simulating a regular Cauchy variate $X$ with scale$^2$ $\gamma$

*Translating the realisation $x$ of $X$ by the proper amount $2n\pi$ so that it belongs to $(-\pi,\pi)$ and returning the resulting $\theta=X+2n\pi$
Furthermore, the Cauchy distribution enjoys closed-form pdf and closed-form inverse pdf, which means that $X$ can be generated by the inverse pdf transform as
$$X = \gamma\tan(\pi U-\pi/2)\qquad U\sim\mathcal U(0,1)$$
Therefore the random variable $\theta\sim f_{WC}(\theta;\gamma)$ can be written (and simulated) as
$$\theta = [\gamma\tan(\pi U-\pi/2)+\pi]\ \text{mod}\,(2\pi) - \pi\tag{1}\qquad U\sim\mathcal U(0,1)$$
As an R code, this translates into
rwauchy <- function(n=1,gamma=1) (tan(pi*(runif(n)-.5))*gamma+pi)%%(2*pi)-pi

and the fit of the histogram with the density $f_{WC}$ is illustrated below


$^1$Formula cut&pasted from Wikipedia.
$^2$The correspondence between $\gamma$ and $p$ is$$\gamma=\tanh^{-1}\frac{1-p^2}{1+p^2}$$
