runif_sphere: Uniform sampling on/in sphere

runif_sphereR Documentation

Uniform sampling on/in sphere

Description

Uniform sampling on a sphere or in a sphere, in arbitrary dimension.

Usage

runif_on_sphere(n, d, r = 1)

runif_in_sphere(n, d, r = 1)

Arguments

n

number of simulations

d

dimension of the space

r

radius of the sphere

Value

The simulations in a n times d matrix.

Examples

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)

uniformly documentation built on March 18, 2022, 6:44 p.m.