powered by
Uniform sampling on a sphere or in a sphere, in arbitrary dimension.
runif_on_sphere(n, d, r = 1)runif_in_sphere(n, d, r = 1)
runif_in_sphere(n, d, r = 1)
The simulations in a n times d matrix.
n
d
number of simulations
dimension of the space
radius of the sphere
sims <- runif_on_sphere(20, d = 2) plot(sims, xlim = c(-1, 1), ylim = c(-1, 1), asp = 1, pch = 19) sims <- runif_in_sphere(100, d = 2) plot(sims, xlim = c(-1, 1), ylim = c(-1, 1), asp = 1, pch = 19)
Run the code above in your browser using DataLab