proj_unif function

Projection of the spherical uniform distribution

Projection of the spherical uniform distribution

Density, distribution, and quantile functions of the projection of the spherical uniform random variable on an arbitrary direction, that is, the random variable γX\gamma'X, where XX

is uniformly distributed on the (hyper)sphere c("Sp1:=\nS^{p-1}:=\n", "xinRp:x=1{x\\in R^p:||x||=1}"), p2p\ge 2, and γSp1\gamma\in S^{p-1} is an arbitrary projection direction. Note that the distribution is invariant to the choice of γ\gamma. Also, efficient simulation of γX\gamma'X.

d_proj_unif(x, p, log = FALSE) p_proj_unif(x, p, log = FALSE) q_proj_unif(u, p) r_proj_unif(n, p)

Arguments

  • x: a vector of size nx or a matrix of size c(nx, 1).
  • p: integer giving the dimension of the ambient space RpR^p that contains Sp1S^{p-1}.
  • log: compute the logarithm of the density or distribution?
  • u: vector of probabilities.
  • n: sample size.

Returns

A matrix of size c(nx, 1) with the evaluation of the density, distribution, or quantile function at x or u. For r_proj_unif, a random vector of size n.

Examples

# Density function curve(d_proj_unif(x, p = 2), from = -2, to = 2, n = 2e2, ylim = c(0, 2)) curve(d_proj_unif(x, p = 3), n = 2e2, col = 2, add = TRUE) curve(d_proj_unif(x, p = 4), n = 2e2, col = 3, add = TRUE) curve(d_proj_unif(x, p = 5), n = 2e2, col = 4, add = TRUE) curve(d_proj_unif(x, p = 6), n = 2e2, col = 5, add = TRUE) # Distribution function curve(p_proj_unif(x, p = 2), from = -2, to = 2, n = 2e2, ylim = c(0, 1)) curve(p_proj_unif(x, p = 3), n = 2e2, col = 2, add = TRUE) curve(p_proj_unif(x, p = 4), n = 2e2, col = 3, add = TRUE) curve(p_proj_unif(x, p = 5), n = 2e2, col = 4, add = TRUE) curve(p_proj_unif(x, p = 6), n = 2e2, col = 5, add = TRUE) # Quantile function curve(q_proj_unif(u = x, p = 2), from = 0, to = 1, n = 2e2, ylim = c(-1, 1)) curve(q_proj_unif(u = x, p = 3), n = 2e2, col = 2, add = TRUE) curve(q_proj_unif(u = x, p = 4), n = 2e2, col = 3, add = TRUE) curve(q_proj_unif(u = x, p = 5), n = 2e2, col = 4, add = TRUE) curve(q_proj_unif(u = x, p = 6), n = 2e2, col = 5, add = TRUE) # Sampling hist(r_proj_unif(n = 1e4, p = 4), freq = FALSE, breaks = 50) curve(d_proj_unif(x, p = 4), n = 2e2, col = 3, add = TRUE)

Author(s)

Eduardo García-Portugués and Paula Navarro-Esteban.

  • Maintainer: Eduardo García-Portugués
  • License: GPL-3
  • Last published: 2024-05-24