The Cauchy distribution is the student's t distribution with one degree of freedom. The Cauchy distribution does not have a well defined mean or variance. Cauchy distributions often appear as priors in Bayesian contexts due to their heavy tails.
dist_cauchy(location, scale)We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.
In the following, let \(X\) be a Cauchy variable with mean
location = \(x_0\) and scale = \(\gamma\).
Support: \(R\), the set of all real numbers
Mean: Undefined.
Variance: Undefined.
Probability density function (p.d.f):
$$ f(x) = \frac{1}{\pi \gamma \left[1 + \left(\frac{x - x_0}{\gamma} \right)^2 \right]} $$
Cumulative distribution function (c.d.f):
$$ F(t) = \frac{1}{\pi} \arctan \left( \frac{t - x_0}{\gamma} \right) + \frac{1}{2} $$
Moment generating function (m.g.f):
Does not exist.
dist <- dist_cauchy(location = c(0, 0, 0, -2), scale = c(0.5, 1, 2, 1))
dist
#> <distribution[4]>
#> [1] Cauchy(0, 0.5) Cauchy(0, 1) Cauchy(0, 2) Cauchy(-2, 1)
mean(dist)
#> [1] NA NA NA NA
variance(dist)
#> [1] NA NA NA NA
skewness(dist)
#> [1] NA NA NA NA
kurtosis(dist)
#> [1] NA NA NA NA
generate(dist, 10)
#> [[1]]
#> [1] 0.05787226 -0.55679129 0.40127920 0.02515888 0.21376813 -0.75566519
#> [7] -1.04594872 0.82954458 1.35507308 -0.65515529
#>
#> [[2]]
#> [1] -1.3979201 -0.2378976 7.7240494 -3.2162135 0.5704357 -4.6870245
#> [7] -0.3316107 -3.2698299 -0.5842548 -3.3093403
#>
#> [[3]]
#> [1] -1.6654672 6.0118352 -1.0199788 -2.1051892 3.1036589 0.7319927
#> [7] 0.6574569 -1.4521469 5.0489551 0.3341891
#>
#> [[4]]
#> [1] -2.042410 -4.945683 -1.495282 -10.171663 -1.582879 -2.116187
#> [7] -1.851471 -1.444466 -2.202221 -2.092369
#>
density(dist, 2)
#> [1] 0.03744822 0.06366198 0.07957747 0.01872411
density(dist, 2, log = TRUE)
#> [1] -3.284796 -2.754168 -2.531024 -3.977943
cdf(dist, 4)
#> [1] 0.9604166 0.9220209 0.8524164 0.9474315
quantile(dist, 0.7)
#> [1] 0.3632713 0.7265425 1.4530851 -1.2734575