wrappedcauchy | R Documentation |
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.
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)
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. |
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 Ω follow a Cauchy distribution and Θ a wrapped Cauchy distribution, where Θ can take values θ \in [-π,π). Pr(Θ ≤ θ) is approximated as
∑^K_{k=-K}Pr(Ω ≤ θ+2π k)-Pr(Ω ≤ -π+2π k).
The quantiles are calculated by numerical inversion.
dwrappedcauchy()
gives a vector of length length(theta)
containing the density at theta
.
pwrappedcauchy()
gives a
vector of length length(theta)
containing
the distribution function at the corresponding values of theta
.
qwrappedcauchy()
gives a vector of length length(p)
containing the quantiles at the corresponding values of p
.
rwrappedcauchy()
generates a vector of length n
containing the random samples, i.e. angles in [-π, π).
circular::dwrappedcauchy()
,
circular::rwrappedcauchy()
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.