bwn {ridgetorus}R Documentation

Density evaluation, sampling, and parameter estimation of the bivariate wrapped normal distribution

Description

Computation of the density of the bivariate wrapped normal.

Simulation of pairs of samples from a bivariate wrapped normal.

Maximum likelihood estimation of the parameters (\boldsymbol{\mu}, \boldsymbol{\Sigma}).

Usage

d_bwn(x, mu, Sigma, kmax = 2)

r_bwn(n, mu, Sigma)

fit_bwn_mle(
  x,
  kmax = 2,
  lower = c(-pi, -pi, 0.001, 0.001, -1),
  upper = c(pi, pi, 20, 20, 1),
  ...
)

Arguments

x

matrix of size c(nx, 2) with the angles on which the density is evaluated.

mu

circular means of the density, a vector of length 2.

Sigma

covariance matrix of size c(2, 2).

kmax

integer number up to truncate the wrapped normal series in -kmax:kmax. Defaults to 2.

n

sample size.

lower, upper

vector of length 5 with the bounds of the parameters for the maximum likelihood optimizer.

...

further parameters passed to mleOptimWrapper.

Value

Examples

## Density evaluation

mu <- c(0, 0)
Sigma <- 3 * matrix(c(1.5, 0.75, 0.75, 1), nrow = 2, ncol = 2)
nth <- 50
th <- seq(-pi, pi, l = nth)
x <- as.matrix(expand.grid(th, th))
d <- d_bwn(x = x, mu = mu, Sigma = Sigma)
filled.contour(th, th, matrix(d, nth, nth), col = viridisLite::viridis(31),
               levels = seq(0, max(d), l = 30))

## Sampling and estimation

n <- 100
samp <- r_bwn(n = 100, mu = mu, Sigma = Sigma)
(param_mle <- fit_bwn_mle(samp)$par)

[Package ridgetorus version 1.0.2 Index]