heavy (version 0.38.196)

rsphere: Generation of Deviates Uniformly Located on a Spherical Surface

Description

Random vector generation uniformly on the sphere.

Usage

rsphere(n = 1, p = 2)

Arguments

n

the number of samples requested

p

dimension of the unitary sphere

Value

If n = 1 a p-dimensional vector, otherwise a matrix of n rows of random vectors.

Details

The function rsphere is an interface to C routines, which make calls to subroutines from BLAS.

References

Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag, New York.

See Also

runif

Examples

Run this code
# NOT RUN {
# generate the sample
z <- rsphere(n = 200)

# scatterplot of a random sample of 200 points uniformly distributed
# on the unit circle
par(pty = "s")
plot(z, xlab = "x", ylab = "y")
title("200 points on the circle", font.main = 1)
# }

Run the code above in your browser using DataCamp Workspace