# unif: Uniform distribution on the hypersphere In rotasym: Tests for Rotational Symmetry on the Hypersphere

 unif R Documentation

## Uniform distribution on the hypersphere

### 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

d_unif_sphere(x, log = FALSE)

r_unif_sphere(n, p)

w_p(p, log = FALSE)


### 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:

• d_unif_sphere: a vector of length nx or 1 with the evaluated density at x.

• r_unif_sphere: a matrix of size c(n, p) with the random sample.

• w_p: the surface area of S^{p-1}.

### Author(s)

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

### Examples

## 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)

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