Cauchy random values in a interval [a, b]

204 Views Asked by At

How do I generate random numbers following a Cauchy distribution in a given interval [a, b]. I tried using explained here Trucated distribution, but did not succeed

1

There are 1 best solutions below

0
On BEST ANSWER

If the distribution of $\Theta$ is uniform on $(-\frac\pi2,\frac\pi2)$ then the distribution of $\tan\Theta$ is Cauchy. Thus, if the distribution of $\Theta$ is uniform on $(\alpha,\beta)$ then the distribution of $\tan\Theta$ is Cauchy restricted to the interval $(\tan\alpha,\tan\beta)$.

To get a Cauchy distribution restricted to the interval $(a,b)$, consider $$X=\tan(\Theta),$$ where the distribution of $\Theta$ is uniform on $(\arctan a,\arctan b)$, for example $$\Theta=\arctan a+(\arctan b-\arctan a)\cdot U,$$ where the distribution of $U$ is uniform on $(0,1)$.