hypersphere.sample | R Documentation |
Generates uniform random variates over an n-hypersphere
hypersphere.sample(n, N)
n |
Dimension of the hypersphere |
N |
Number of samples |
A single n-dimensional sample from the hypersphere.
Tommi Tervonen <tommi@smaa.fi>
n <- 3 # Dimension N <- 5 # Nr samples sample <- hypersphere.sample(n, N) # Check summing to unity vec.norm <- function(x) { sum(x^2) } stopifnot(all.equal(apply(sample, 1, vec.norm), rep(1, N)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.