Cauchy distribution
cauchy.RdScalar Cauchy utilities implemented for NIMBLE compatibility. These functions support symmetric heavy-tailed kernels on the real line and feed directly into the finite Cauchy mixture family.
Usage
dCauchy(x, location, scale, log = 0)
pCauchy(q, location, scale, lower.tail = 1, log.p = 0)
rCauchy(n, location, scale)
qCauchy(p, location, scale, lower.tail = TRUE, log.p = FALSE)Arguments
- x
Numeric scalar giving the point at which the density is evaluated.
- location
Numeric scalar location parameter.
- scale
Numeric scalar scale parameter; must be positive.
- log
Logical; if
TRUE, return the log-density (integer flag0/1in NIMBLE).- q
Numeric scalar giving the point at which the distribution function is evaluated.
- lower.tail
Logical; if
TRUE(default), probabilities are \(P(X \le q)\).- log.p
Logical; if
TRUE, probabilities are returned on the log scale.- n
Integer giving the number of draws. For portability inside NIMBLE, the RNG implementation supports
n = 1.- p
Numeric scalar probability in \((0,1)\) for the quantile function.
Value
dCauchy() returns a numeric scalar density, pCauchy() returns a numeric scalar CDF,
rCauchy() returns one random draw, and qCauchy() returns a numeric quantile.
Details
The density is
$$
f(x) = \frac{1}{\pi s \{1 + ((x - \ell)/s)^2\}},
$$
where location = ell and scale = s > 0.
These uppercase NIMBLE-compatible functions are scalar (x/q and n = 1).
For vectorized R usage, use base_lowercase().
The Cauchy law is a stable heavy-tailed distribution with undefined mean and variance. That is why the package allows the Cauchy kernel only as a bulk distribution and deliberately does not pair it with GPD tails in the kernel registry. For predictive summaries, ordinary means are not available under Cauchy kernels; medians, quantiles, survival curves, and restricted means remain well defined.
The distribution function is $$ F(x) = \frac{1}{2} + \frac{1}{\pi}\arctan\left(\frac{x-\ell}{s}\right), $$ and the quantile is the corresponding inverse $$ Q(p) = \ell + s \tan\{\pi(p-1/2)\}. $$
Functions
dCauchy(): Cauchy density functionpCauchy(): Cauchy distribution functionrCauchy(): Cauchy random generationqCauchy(): Cauchy quantile function
See also
Examples
location <- 0
scale <- 1.5
dCauchy(0.5, location, scale, log = 0)
#> [1] 0.1909859
pCauchy(0.5, location, scale, lower.tail = 1, log.p = 0)
#> [1] 0.6024164
qCauchy(0.50, location, scale)
#> [1] 0
qCauchy(0.95, location, scale)
#> [1] 9.470627
replicate(10, rCauchy(1, location, scale))
#> [1] 1.136833615 9.204051106 -2.358070842 -1.849573362 0.953006225
#> [6] -0.005439956 0.715536658 0.826377778 -4.820583192 1.654735475