Draw samples from a standard Cauchy distribution with mode = 0.
Also known as the Lorentz distribution.
size (int or tuple of ints, optional) – Output shape. If the given shape is, e.g., (m, n, k), then
m * n * k samples are drawn. Default is None, in which case a
single value is returned.
(m, n, k)
m * n * k
chunk_size (int or tuple of int or tuple of ints, optional) – Desired chunk size on each dimension
gpu (bool, optional) – Allocate the tensor on GPU if True, False as default
dtype (data-type, optional) – Data-type of the returned tensor.
samples – The drawn samples.
Tensor or scalar
The probability density function for the full Cauchy distribution is
and the Standard Cauchy distribution just sets \(x_0=0\) and
The Cauchy distribution arises in the solution to the driven harmonic
oscillator problem, and also describes spectral line broadening. It
also describes the distribution of values at which a line tilted at
a random angle will cut the x axis.
When studying hypothesis tests that assume normality, seeing how the
tests perform on data from a Cauchy distribution is a good indicator of
their sensitivity to a heavy-tailed distribution, since the Cauchy looks
very much like a Gaussian distribution, but with heavier tails.
NIST/SEMATECH e-Handbook of Statistical Methods, “Cauchy
Weisstein, Eric W. “Cauchy Distribution.” From MathWorld–A
Wolfram Web Resource.
Wikipedia, “Cauchy distribution”
Draw samples and plot the distribution:
>>> import mars.tensor as mt
>>> import matplotlib.pyplot as plt
>>> s = mt.random.standard_cauchy(1000000)
>>> s = s[(s>-25) & (s<25)] # truncate distribution so it plots well
>>> plt.hist(s.execute(), bins=100)