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)

## Arguments

location, scale

location and scale parameters.

## Details

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.

## Examples

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.40539335  0.04872854 -0.38930015  0.28854323  0.04522432 -0.39812833
#>  [7] -0.30573560 -0.05481830  1.24727332  0.30507601
#>
#> [[2]]
#>  [1] -2.95861067 -0.70063752  0.11574452 -1.11358259  0.80255841  0.05031776
#>  [7]  0.42753625 -1.51133039 -2.09189744  1.65908916
#>
#> [[3]]
#>  [1]  5.4202923 -2.6206212 -2.7958402 -0.4757952 15.4480989 -6.4324270
#>  [7]  1.1408714 -9.3740490 -0.6632214 -6.5396597
#>
#> [[4]]
#>  [1] -2.5842548 -5.3093403 -2.8327336  1.0059176 -2.5099894 -3.0525946
#>  [7] -0.4481705 -1.6340037 -1.6712715 -2.7260734
#>

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