Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Random points on a hypersphere
N <- 1000
nDims <- 2
randomNumbers <- rnorm(nDims * N, 0, 1)
randomNumbers <- matrix(randomNumbers, ncol = nDims)
plot(randomNumbers)
radius = sqrt(rowSums(randomNumbers ^ 2))
randomSphere <- 1/radius * randomNumbers
plot(randomSphere)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.