flopscope.numpy.random.RandomState.standard_cauchy
fnp.random.RandomState.standard_cauchy(self, size=None)
Draw samples from a standard Cauchy distribution with mode = 0.
Adapted from NumPy docs np.random.RandomState.standard_cauchy
Legacy standard Cauchy; cost = numel(output).
Also known as the Lorentz distribution.
New code should use the standard_cauchy method of a Generator instance instead; please see the random-quick-start.
Parameters
- size:int or tuple of ints, optional
Output shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. Default is None, in which case a single value is returned.
Returns
- samples:ndarray or scalar
The drawn samples.
See also
- we.flops.random.Generator.standard_cauchy which should be used for new code.
Notes
The probability density function for the full Cauchy distribution is
and the Standard Cauchy distribution just sets 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.
References
1
NIST/SEMATECH e-Handbook of Statistical Methods, "Cauchy
Distribution",
https://www.itl.nist.gov/div898/handbook/eda/section3/eda3663.htm2
Weisstein, Eric W. "Cauchy Distribution." From MathWorld--A
Wolfram Web Resource.
https://mathworld.wolfram.com/CauchyDistribution.html3
Wikipedia, "Cauchy distribution"
https://en.wikipedia.org/wiki/Cauchy_distributionExamples
Draw samples and plot the distribution:
>>> import matplotlib.pyplot as plt
>>> s = flops.random.standard_cauchy(1000000)
>>> s = s[(s>-25) & (s<25)] # truncate distribution so it plots well
>>> plt.hist(s, bins=100)
>>> plt.show()