This is a modified version of dwrpnorm
in the CircStats
package
to allow for multiple angles at once (i.e., vectorized on theta
and mu
).
dwrpnorm2(theta, mu, rho, sd = 1, acc = 1e-05, tol = acc)
value at which to evaluate the density function, measured in radians.
mean direction of distribution, measured in radians.
mean resultant length of distribution.
different way of select rho, see details below.
parameter defining the accuracy of the estimation of the density. Terms are added to the infinite summation that defines the density function until successive estimates are within acc of each other.
same as acc
.
# Values for which to evaluate density
theta <- c(1:500) * 2 * pi / 500
# Compute wrapped normal density function
density <- c(1:500)
for(i in 1:500) {
density[i] <- dwrpnorm2(theta[i], pi, .75)
}
if (interactive()) {
plot(theta, density)
}
# Approximate area under density curve
sum(density * 2 * pi / 500)
#> [1] 1