Density, distribution, and quantile functions of the projection of the spherical uniform random variable on an arbitrary direction, that is, the random variable γ′X, where X
is uniformly distributed on the (hyper)sphere c("Sp−1:=\n", "xinRp:∣∣x∣∣=1"), p≥2, and γ∈Sp−1 is an arbitrary projection direction. Note that the distribution is invariant to the choice of γ. Also, efficient simulation of γ′X.
x: a vector of size nx or a matrix of size c(nx, 1).
p: integer giving the dimension of the ambient space Rp that contains Sp−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 functioncurve(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 functioncurve(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 functioncurve(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)# Samplinghist(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.