Skip to contents

qmc_sample(n, d, sampler) returns a d x n matrix of points in the unit box; qmc_sample(n, lb, ub, sampler) maps them to the box with lower bounds lb and upper bounds ub. This is QuasiMonteCarlo.sample, renamed because base::sample() is not generic. A function of k returning k random numbers (for example function(k) rnorm(k)) is also accepted as a sampler, as the Distributions extension of QuasiMonteCarlo accepts a distribution.

Usage

qmc_sample(n, d, ub, sampler)

Arguments

n

Number of points.

d

Dimension, or the lower bounds lb when ub is given.

ub

Upper bounds, or the sampler in the unit box form.

sampler

A sampler from qmc_samplers.

Value

A matrix with one point per column.

Examples

qmc_sample(4, 1, VanDerCorputSample(2))
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] 0.125 0.625 0.375 0.875