CauchyDistribution
Represents the Cauchy distribution (also known as the Lorentz distribution).
The Cauchy distribution is a symmetric, heavy-tailed continuous distribution centered at location. It is famous for having no defined mean, variance, or higher moments -- all of these properties return Double.NaN. This happens because the tails are so heavy that the integrals defining these moments diverge.
A common way the Cauchy distribution arises in practice is as the ratio of two independent standard normal random variables. It also describes the distribution of the tangent of a uniformly distributed angle and appears in physics as the line shape of spectral lines (where it is called a Lorentzian).
The distribution is supported on the entire real line, from negative infinity to positive infinity. The scale parameter controls how spread out the distribution is around the location (analogous to standard deviation in a normal distribution, but the Cauchy distribution decays much more slowly in the tails).
The quantile function has a closed-form expression using the tangent function, so sampling is performed via inverse CDF (no iterative root-finding is needed).
Example:
val cauchy = CauchyDistribution(location = 0.0, scale = 1.0)
cauchy.pdf(0.0) // 0.3183... (peak density at the location)
cauchy.cdf(0.0) // 0.5 (symmetric around the location)
cauchy.quantile(0.75) // 1.0 (third quartile of the standard Cauchy)
cauchy.mean // NaN (the mean is undefined)
cauchy.entropy // 2.5310... (entropy is defined even though moments are not)
cauchy.sample(Random(42)) // a single random drawTypes
Properties
Returns Double.NaN because the Cauchy distribution has no defined kurtosis.
Returns Double.NaN because the Cauchy distribution has no defined mean.
Returns Double.NaN because the Cauchy distribution has no defined skewness.
Returns Double.NaN because the Cauchy distribution has no defined standard deviation.
Returns Double.NaN because the Cauchy distribution has no defined variance.