rsphere | R Documentation |
Random vector generation uniformly on the sphere.
rsphere(n = 1, p = 2)
n |
the number of samples requested |
p |
dimension of the unitary sphere |
The function rsphere
is an interface to C routines, which make calls to
subroutines from BLAS.
If n = 1
a p
-dimensional vector, otherwise a matrix of n
rows of random vectors.
Devroye, L. (1986). Non-Uniform Random Variate Generation. Springer-Verlag, New York.
runif
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.