wrappedcauchy {cylcop} | R Documentation |
Density, Distribution, Quantiles and Random Number Generation for the Wrapped Cauchy Distribution
Description
The distribution function (pwrappedcauchy()
) and quantiles
(qwrappedcauchy()
) of the wrapped Cauchy distribution cannot
be obtained analytically. They are therefore missing in the
'circular' package and are obtained here numerically.
Random number generation (rwrappedcauchy()
) and density
(dwrappedcauchy()
) don't need a numerical
approximation and are provided here for consistency in parametrization
with the other wrapped Cauchy functions.
Usage
rwrappedcauchy(n, location = 0, scale = 1)
dwrappedcauchy(theta, location = 0, scale = 1)
pwrappedcauchy(theta, location = 0, scale = 1, K = 100, check_prec = FALSE)
qwrappedcauchy(p, location = 0, scale = 1, K = 100, check_prec = FALSE)
Arguments
n |
integer value, the number of random samples to be
generated with |
location |
numeric value, the mean of the distribution. |
scale |
numeric value, the parameter tuning the spread of the density. It must be non-negative. |
theta |
numeric vector giving the angles where the density or distribution function is evaluated. |
K |
integer value, the number of "wraps" used in each direction to approximate the distribution. |
check_prec |
logical, whether to check if the precision of the numerical approximation with the current parameters is higher than 99%. |
p |
numeric vector giving the probabilities where the quantile function is evaluated. |
Details
One could alternatively convert scale
to rho
via
rho = exp(-scale)
and use
circular::rwrappedcauchy(theta, mu=location rho=rho)
or
circular::dwrappedcauchy(theta, mu=location rho=rho)
.
The wrapped Cauchy cdf, for which there is no analytical expression,
is calculated by wrapping the Cauchy distribution K
times
around the circle in each direction and summing the Cauchy cdfs at each point of
the circle. Let \Omega
follow a Cauchy distribution and
\Theta
a wrapped Cauchy distribution, where \Theta
can take values
\theta \in [-\pi,\pi)
.
Pr(\Theta \le \theta)
is approximated as
\sum^K_{k=-K}Pr(\Omega \le \theta+2\pi k)-Pr(\Omega \le -\pi+2\pi k).
The quantiles are calculated by numerical inversion.
Value
dwrappedcauchy()
gives a vector of lengthlength(theta)
containing the density attheta
.pwrappedcauchy()
gives a vector of lengthlength(theta)
containing the distribution function at the corresponding values oftheta
.qwrappedcauchy()
gives a vector of lengthlength(p)
containing the quantiles at the corresponding values ofp
.rwrappedcauchy()
generates a vector of lengthn
containing the random samples, i.e. angles in[-\pi, \pi)
.
See Also
circular::dwrappedcauchy()
,
circular::rwrappedcauchy()
.
Examples
set.seed(123)
rwrappedcauchy(10, location = 0, scale =3)
dwrappedcauchy(c(0.1, pi), location = pi, scale =2)
circular::dwrappedcauchy(circular::circular(c(0.1,pi)), mu = circular::circular(pi), rho =exp(-2))
prob <- pwrappedcauchy(c(0.1, pi), location = pi, scale =2)
prob
qwrappedcauchy(prob, location = pi, scale =2)