Skip to content

Instantly share code, notes, and snippets.

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)
radius = sqrt(rowSums(randomNumbers ^ 2))
randomSphere <- 1/radius * randomNumbers
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.