runif3 | R Documentation |
Generate randomly oriented vectors in 3D, following an isotropic distribution (optionally truncated to a region).
runif3(
n = 1,
r = c(0, 1),
azimuth = c(0, 2 * pi),
polarangle = c(0, pi),
quasi = FALSE,
start = 1
)
n |
number of random vectors to be generated |
r |
2-vector specifying the range of radii |
azimuth |
2-vector specifying the range of azimuth angles (maximum range 0..2*pi) |
polarangle |
2-vector specifying the range of polar angles (maximum range 0..pi) |
quasi |
logical flag. If true, quasi-random numbers with low-discrepancy are drawn, based on a Halton sequence. Otherwise, the standard internal pseudo-random generator of |
start |
starting index of Halton sequence. Only used if |
Returns an n-by-3 array of n vectors.
Danail Obreschkow
runif2
## draw 20 unit vectors on a sphere
x = runif3(20,r=c(1,1))
print(rowSums(x^2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.