tangent-elliptical | R Documentation |
Density and simulation of the Tangent Elliptical (TE)
distribution on
S^{p-1}:=\{\mathbf{x}\in R^p:||\mathbf{x}||=1\}
, p\ge 2
. The distribution arises
by considering the
tangent-normal decomposition with
multivariate signs distributed as an
Angular Central Gaussian distribution.
d_TE(x, theta, g_scaled, d_V, Lambda, log = FALSE)
r_TE(n, theta, r_V, Lambda)
x |
locations in |
theta |
a unit norm vector of size |
g_scaled |
the scaled angular density |
d_V |
the density |
Lambda |
the shape matrix |
log |
flag to indicate if the logarithm of the density (or the normalizing constant) is to be computed. |
n |
sample size, a positive integer. |
r_V |
a function for simulating |
The functions are wrappers for d_tang_norm
and
r_tang_norm
with d_U = d_ACG
and
r_U = r_ACG
.
Depending on the function:
d_TE
: a vector of length nx
or 1
with the
evaluated density at x
.
r_TE
: a matrix of size c(n, p)
with the random sample.
Eduardo García-Portugués, Davy Paindaveine, and Thomas Verdebout.
García-Portugués, E., Paindaveine, D., Verdebout, T. (2020) On optimal tests for rotational symmetry against new classes of hyperspherical distributions. Journal of the American Statistical Association, 115(532):1873–1887. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2019.1665527")}
tang-norm-decomp
,
tangent-vMF
, ACG
.
## Simulation and density evaluation for p = 2
# Parameters
p <- 2
n <- 1e3
theta <- c(rep(0, p - 1), 1)
Lambda <- matrix(0.5, nrow = p - 1, ncol = p - 1)
diag(Lambda) <- 1
kappa_V <- 2
# Required functions
r_V <- function(n) r_g_vMF(n = n, p = p, kappa = kappa_V)
g_scaled <- function(t, log) {
g_vMF(t, p = p - 1, kappa = kappa_V, scaled = TRUE, log = log)
}
# Sample and color according to density
x <- r_TE(n = n, theta = theta, r_V = r_V, Lambda = Lambda)
col <- viridisLite::viridis(n)
r <- runif(n, 0.95, 1.05) # Radius perturbation to improve visualization
dens <- d_TE(x = x, theta = theta, g_scaled = g_scaled, Lambda = Lambda)
plot(r * x, pch = 16, col = col[rank(dens)])
## Simulation and density evaluation for p = 3
# Parameters
p <- 3
n <- 5e3
theta <- c(rep(0, p - 1), 1)
Lambda <- matrix(0.5, nrow = p - 1, ncol = p - 1)
diag(Lambda) <- 1
kappa_V <- 2
# Sample and color according to density
x <- r_TE(n = n, theta = theta, r_V = r_V, Lambda = Lambda)
col <- viridisLite::viridis(n)
dens <- d_TE(x = x, theta = theta, g_scaled = g_scaled, Lambda = Lambda)
if (requireNamespace("rgl")) {
rgl::plot3d(x, col = col[rank(dens)], size = 5)
}
## A non-vMF angular function: g(t) = 1 - t^2. It is sssociated to the
## Beta(1/2, (p + 1)/2) distribution.
# Scaled angular function
g_scaled <- function(t, log) {
log_c_g <- lgamma(0.5 * p) + log(0.5 * p / (p - 1)) - 0.5 * p * log(pi)
log_g <- log_c_g + log(1 - t^2)
switch(log + 1, exp(log_g), log_g)
}
# Simulation
r_V <- function(n) {
sample(x = c(-1, 1), size = n, replace = TRUE) *
sqrt(rbeta(n = n, shape1 = 0.5, shape2 = 0.5 * (p + 1)))
}
# Sample and color according to density
kappa_V <- 1
Lambda <- matrix(0.75, nrow = p - 1, ncol = p - 1)
diag(Lambda) <- 1
x <- r_TE(n = n, theta = theta, r_V = r_V, Lambda = Lambda)
col <- viridisLite::viridis(n)
dens <- d_TE(x = x, theta = theta, g_scaled = g_scaled, Lambda = Lambda)
if (requireNamespace("rgl")) {
rgl::plot3d(x, col = col[rank(dens)], size = 5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.