Python: how to randomly sample from nonstandard Cauchy distribution, hence with different parameters?

Viewed 5835

I was looking here: numpy

And I can see you can use the command np.random.standard_cauchy() specifying an array, to sample from a standard Cauchy.

I need to sample from a Cauchy which might have x_0 != 0 and gamma != 1, i.e. might not be located at the origin, nor have scale equal to 1.

How can I do this?

2 Answers

You may avoid the dependency on SciPy, since the Cauchy distribution is part of the location-scale family. That means, if you draw a sample x from Cauchy(0, 1), just shift it by x_0 and multiply with gamma and x' = x_0 + gamma * x will be distributed according to Cauchy(x_0, gamma).

Related