Simulates uniform random variates from the hypersphere.
Usage
rhypersphere(n, dim = 2, radius = 1, center = rep(0, dim), type = "boundary")
Value
The function returns a vector of random variates.
Arguments
n
number of observations to simulate.
dim
dimensions of hypersphere.
radius
radius of hypersphere.
center
center of hypersphere.
type
character; if "boundary" (default) then random variates
are simulated from the hypersphere. If "inside" random
variates are points lying inside the hypersphere. If "non-uniform"
then random variates are non-uniform and simulated from the inner part
of the hypersphere simply by making radius a uniform random variable
between 0 and radius.
set.seed(123)
# Get 5 random uniform variates from 3D hypersphere# of radius 10 centered at (2, 3, 1)rhypersphere(n = 5, dim = 3, radius = 10, center = c(2, 3, 1))