Learn R Programming

vdg (version 1.1.3)

runif_cube: Sampling for hyperspheres/hypercubes

Description

Sample uniformly in or on a hyperspheres or hypercubes.

Usage

runif_cube(n, m = 2, max.dist = 1, at = FALSE, nr.dist = 21)
runif_sphere(n, m = 2, max.radius = sqrt(m), at = FALSE, nr.rad = 21)

Arguments

n
number of points to sample
m
number of design factors
max.dist
maximum distance from origin (L-infinity norm/supremum distance) for the hypercuboidal design region (enveloping hypercube)
at
logical indicating whether to sample on concentric hyperspheres/hypercubes or not. With this option n is distributed proportionally across radii / supremum distances so that the density of samples on each concentric hypercube / hypersphere are uniform across the different hyperspheres / hypercubes..
nr.dist
the number of concentric hypercubes to use in case at is TRUE
max.radius
maximum radius of the hyperspherical design region (enveloping hypersphere)
nr.rad
number of concentric hyperspheres to sample on in case of at being TRUE

Examples

Run this code

set.seed(1234)
runif_sphere(n = 10)

set.seed(1234)
samp <- runif_sphere(n = 500, at = TRUE)
plot(samp, asp = 1)

Run the code above in your browser using DataLab