unif: Uniform distribution on the hypersphere

Description Usage Arguments Details Value Author(s) Examples

Description

Density and simulation of the uniform distribution on S^{p-1} := {x \in R^p : ||x|| = 1}, p≥ 1. The density is just the inverse of the surface area of S^{p-1}, given by

ω_p := 2π^{p/2} / Γ(p/2).

Usage

1
2
3
4
5

Arguments

x

locations in S^{p-1} to evaluate the density. Either a matrix of size c(nx, p) or a vector of length p. Normalized internally if required (with a warning message).

log

flag to indicate if the logarithm of the density (or the normalizing constant) is to be computed.

n

sample size, a positive integer.

p

dimension of the ambient space R^p that contains S^{p-1}. A positive integer.

Details

If p = 1, then S^{0} = \{-1, 1\} and the "surface area" is 2. The function w_p is vectorized on p.

Value

Depending on the function:

Author(s)

Eduardo García-Portugués, Davy Paindaveine, and Thomas Verdebout.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Area of S^{p - 1}

# Areas of S^0, S^1, and S^2
w_p(p = 1:3)

# Area as a function of p
p <- 1:20
plot(p, w_p(p = p), type = "o", pch = 16, xlab = "p", ylab = "Area",
     main = expression("Surface area of " * S^{p - 1}), axes = FALSE)
box()
axis(1, at = p)
axis(2, at = seq(0, 34, by = 2))

## Simulation and density evaluation for p = 1, 2, 3

# p = 1
n <- 500
x <- r_unif_sphere(n = n, p = 1)
barplot(table(x) / n)
head(d_unif_sphere(x))

# p = 2
x <- r_unif_sphere(n = n, p = 3)
plot(x)
head(d_unif_sphere(x))

# p = 3
x <- r_unif_sphere(n = n, p = 3)
if (requireNamespace("rgl")) {
  rgl::plot3d(x)
}
head(d_unif_sphere(x))

rotasym documentation built on Oct. 18, 2021, 5:09 p.m.