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


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?

  • 3
    $\begingroup$ Probability integral transform? $\endgroup$
    – Dave
    Apr 15, 2021 at 10:46
  • $\begingroup$ Thanks, yes looks like a probability integral transform is good to make a map between the distributions. Yes @Xi'an the $x$ is between - pi and pi $\endgroup$ Apr 15, 2021 at 15:34
  • $\begingroup$ You mean you are looking for a quantile function? math.stackexchange.com/questions/2911792/… $\endgroup$ Apr 19, 2021 at 20:35
  • $\begingroup$ Are you just trying to replace the wrapped Cauchy with scale parameter $p$ with a Uniform distribution with support (or scale) parameter $q$ by equating some moments? The graph of the density of a wrapped Cauchy distribution shows how much it differs from a Uniform. Besides, its support is always $(-\pi,\pi)$, for all $p$'s, which would suggest using $q=\pi$. $\endgroup$
    – Xi'an
    Apr 21, 2021 at 14:52

1 Answer 1


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

  1. Simulating a regular Cauchy variate $X$ with scale$^2$ $\gamma$
  2. 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

enter image description here

$^1$Formula cut&pasted from Wikipedia.

$^2$The correspondence between $\gamma$ and $p$ is$$\gamma=\tanh^{-1}\frac{1-p^2}{1+p^2}$$

  • $\begingroup$ Thanks @Xi'an I forgot to mention my wrapping for the Cauchy distribution, but I also get this. Now I'd like to have a map between a uniform distribution and the wrapped Cauchy....if this is even possible, perhaps a rough map would work for low values? $\endgroup$ Apr 19, 2021 at 11:55
  • $\begingroup$ thanks, so I start with my uniform distribution $U(q)$ and generate a random number between $-q$ and $q$. I put this into eqn (1), and I'd like to find $p$. We know how $p$ and $\gamma$ relate. Eqn(1) gives me $\theta$ given some $\gamma$ and my random number. I'm not sure we know enough? $\endgroup$ Apr 20, 2021 at 10:04
  • $\begingroup$ Because all I know is the $q$ I used to generate the random number from $U[-q,q]$ and now I'd like an equivalent $p$, if possible? $\endgroup$ Apr 20, 2021 at 10:26
  • $\begingroup$ Could I pick a $\theta$ to assess the equation at, say, in the tail of the distribution? $\endgroup$ Apr 20, 2021 at 10:42
  • $\begingroup$ So I decided to test the distributions at 25%. For the uniform distribution, that occurs at $x=0.25*(q--q) + -q = -0.5q$. I wrote code to find the 25% in the wrapped cauchy: prange = np.linspace(0.05,0.95,1000) twentyfive = np.zeros(len(prange)) for pp in range(len(prange)): wc_int = np.arctan2(prange[pp]-1,(prange[pp]+1)*np.tan(x/2))/np.pi plt.plot(x,wc_int+1) twentyfive[pp] = wc_int.flat[np.abs(wc_int +1 - 0.25).argmin()] plt.show() plt.plot(prange,twentyfive) plt.show() plt.plot(twentyfive/-0.5) but I'm not sure it matches well $\endgroup$ Apr 20, 2021 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.