| wrpnorm | R Documentation |
Density, distribution function, and random generation for the wrapped normal distribution.
dwrpnorm(x, mu = 0, sigma, log = FALSE)
pwrpnorm(q, mu = 0, sigma, from = NULL, lower.tail = TRUE, log.p = FALSE)
rwrpnorm(n, mu = 0, sigma)
x, q |
vector of angles in radians. |
mu |
mean direction in radians. |
sigma |
standard deviation of the normal distribution before wrapping, must be positive. |
log, log.p |
logical; if |
from |
origin, in radians, at which the circle is cut open for the distribution function. If |
lower.tail |
logical; if |
n |
number of random values to return. |
This implementation allows for automatic differentiation with RTMB.
The wrapped normal is the distribution of Y \bmod 2\pi for a normal
Y with mean \mu and standard deviation \sigma, with density
f(x;\,\mu,\sigma) = \sum_{k=-\infty}^{\infty} \frac{1}{\sigma}\,\phi\!\left(\frac{x - \mu + 2\pi k}{\sigma}\right)
= \frac{1}{2\pi}\left(1 + 2\sum_{k=1}^{\infty} e^{-k^2\sigma^2/2} \cos(k(x - \mu))\right).
For \sigma < 2 the first sum is used with |k| \le 3, otherwise the
second with k \le 4; the terms left out are below 10^{-20}.
The distribution function cuts the circle open at \mu - \pi by default,
or at from, exactly as pwrpcauchy does, where the choice
of origin and the one-step-ahead (OSA) residuals are explained. As there, OSA
residuals via RTMB::oneStepPredict with
method = "cdf" cut the circle at the fixed origin -\pi.
dwrpnorm gives the density, pwrpnorm gives the distribution function, and rwrpnorm generates random deviates in [-\pi, \pi).
wrpcauchy, vm, card; cjw() for circular-linear copulas.
set.seed(1)
x <- rwrpnorm(10, 0, 0.8)
d <- dwrpnorm(x, 0, 0.8)
p <- pwrpnorm(x, 0, 0.8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.