Cauchy | R Documentation |
The Cauchy distribution is an absolute continuous probability distribution
characterized by its location parameter x_0
and scale parameter
\gamma > 0
.
Cauchy(location = 0, scale = 1)
## S4 method for signature 'Cauchy,numeric'
d(distr, x, log = FALSE)
## S4 method for signature 'Cauchy,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Cauchy,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)
## S4 method for signature 'Cauchy,numeric'
r(distr, n)
## S4 method for signature 'Cauchy'
mean(x)
## S4 method for signature 'Cauchy'
median(x)
## S4 method for signature 'Cauchy'
mode(x)
## S4 method for signature 'Cauchy'
var(x)
## S4 method for signature 'Cauchy'
sd(x)
## S4 method for signature 'Cauchy'
skew(x)
## S4 method for signature 'Cauchy'
kurt(x)
## S4 method for signature 'Cauchy'
entro(x)
## S4 method for signature 'Cauchy'
finf(x)
llcauchy(x, location, scale)
## S4 method for signature 'Cauchy,numeric'
ll(distr, x)
ecauchy(x, type = "mle", ...)
## S4 method for signature 'Cauchy,numeric'
mle(
distr,
x,
par0 = "me",
method = "L-BFGS-B",
lower = c(-Inf, 1e-05),
upper = c(Inf, Inf),
na.rm = FALSE
)
## S4 method for signature 'Cauchy,numeric'
me(distr, x, na.rm = FALSE)
vcauchy(location, scale, type = "mle")
## S4 method for signature 'Cauchy'
avar_mle(distr)
location , scale |
numeric. Location and scale parameters. |
distr |
an object of class |
x |
For the density function, |
log , log.p |
logical. Should the logarithm of the probability be returned? |
q |
numeric. Vector of quantiles. |
lower.tail |
logical. If TRUE (default), probabilities are
|
p |
numeric. Vector of probabilities. |
n |
number of observations. If |
type |
character, case ignored. The estimator type (mle or me). |
... |
extra arguments. |
par0 , method , lower , upper |
arguments passed to optim for the mle optimization. |
na.rm |
logical. Should the |
The probability density function (PDF) of the Cauchy distribution is given by:
f(x; x_0, \gamma) = \frac{1}{\pi \gamma \left[1 + \left(\frac{x -
x_0}{\gamma}\right)^2\right]}.
The MLE of the Cauchy distribution parameters is not available in closed form
and has to be approximated numerically. This is done with optim()
.
The default method used is the L-BFGS-B method with lower bounds
c(-Inf, 1e-5)
and upper bounds c(Inf, Inf)
. The par0
argument can
either be a numeric (both elements satisfying lower <= par0 <= upper
)
or a character specifying the closed-form estimator to be used as
initialization for the algorithm ("me"
- the default value).
Note that the me()
estimator for the Cauchy distribution is not a
moment estimator; it utilizes the sample median instead of the sample
mean.
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (distr
), the
d()
, p()
, q()
, r()
, ll()
functions return the density, cumulative
probability, quantile, random sample generator, and log-likelihood functions,
respectively. When supplied with both arguments (distr
and x
), they
evaluate the aforementioned functions directly.
Moments: Returns a numeric, either vector or matrix depending on the moment
and the distribution. The moments()
function returns a list with all the
available methods.
Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
Functions from the stats
package: dcauchy()
, pcauchy()
, qcauchy()
,
rcauchy()
# -----------------------------------------------------
# Cauchy Distribution Example
# -----------------------------------------------------
# Create the distribution
x0 <- 3 ; scale <- 5
D <- Cauchy(x0, scale)
# ------------------
# dpqr Functions
# ------------------
d(D, c(-5, 3, 10)) # density function
p(D, c(-5, 3, 10)) # distribution function
qn(D, c(0.4, 0.8)) # inverse distribution function
x <- r(D, 100) # random generator function
# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself
# ------------------
# Moments
# ------------------
median(D) # Median
mode(D) # Mode
entro(D) # Entropy
finf(D) # Fisher Information Matrix
# ------------------
# Point Estimation
# ------------------
ll(D, x)
llcauchy(x, x0, scale)
ecauchy(x, type = "mle")
ecauchy(x, type = "me")
mle(D, x)
me(D, x)
e(D, x, type = "mle")
mle("cauchy", x) # the distr argument can be a character
# ------------------
# Estimator Variance
# ------------------
vcauchy(x0, scale, type = "mle")
avar_mle(D)
v(D, type = "mle")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.