proj_unif {sphunif} | R Documentation |
Projection of the spherical uniform distribution
Description
Density, distribution, and quantile functions of the
projection of the spherical uniform random variable on an arbitrary
direction, that is, the random variable
\boldsymbol{\gamma}'{\bf X}
, where {\bf X}
is uniformly distributed on the (hyper)sphere
S^{p-1}:=\{{\bf x}\in R^p:||{\bf x}||=1\}
, p\ge 2
, and
\boldsymbol{\gamma}\in S^{p-1}
is an
arbitrary projection direction. Note that the distribution is
invariant to the choice of \boldsymbol{\gamma}
. Also,
efficient simulation of \boldsymbol{\gamma}'{\bf X}
.
Usage
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 |
p |
integer giving the dimension of the ambient space |
log |
compute the logarithm of the density or distribution? |
u |
vector of probabilities. |
n |
sample size. |
Value
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
.
Author(s)
Eduardo García-Portugués and Paula Navarro-Esteban.
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)