# qrng: Compute Quasi-Random Sequences In qrng: (Randomized) Quasi-Random Number Generators

## Description

Computing Korobov, generalize Halton and Sobol' quasi-random sequences.

## Usage

 ```1 2 3 4``` ```korobov(n, d = 1, generator, randomize = c("none", "shift")) ghalton(n, d = 1, method = c("generalized", "halton")) sobol (n, d = 1, randomize = c("none", "digital.shift", "Owen", "Faure.Tezuka", "Owen.Faure.Tezuka"), seed, skip = 0, ...) ```

## Arguments

 `n` number n of points to be generated >= 2. `d` dimension d. `generator` `numeric` of length d or length 1 (in which case it is appropriately extended to length d). All numbers must be in {1,...,n} and must be (coercible to) integers. `randomize` `character` string indicating the type of randomization for the point set. `korobov()`one of the following: "none"no randomization. "shift"a uniform random variate modulo 1. `sobol()`one of the following: `"none"`no randomization. "digital.shift"a digital shift. "Owen", "Faure.Tezuka","Owen.Faure.Tezuka"calls `sobol()` from package randtoolbox with `scrambling` being 1, 2 and 3, respectively. If `randomize` is a `logical`, then it is interpreted as `"none"` if `FALSE` and `"digital.shift"` if `TRUE`. `method` `character` string indicating which sequence is generated, generalized Halton or (plain) Halton. `seed` if provided, an integer used within `set.seed()` for the non-scrambling `randomize` methods (so `"none"` or `"digital.shift"`) or passed to the underlying `sobol()` from package randtoolbox for the scrambling methods. If not provided, the non-scrambling methods respect a global `set.seed()` but the scrambling methods do not (they then use 4711 as default); see `sobol()` from package randtoolbox for details. `skip` number of initial points in the sequence to be skipped (`skip = 0` means the sequence starts with at the origin). Note that for the scrambling methods this simply computes ```n + skip``` points and omits the first `skip`-many. `...` additional arguments passed to `sobol()` from package randtoolbox.

## Details

For `sobol()` examples see `demo(sobol_examples)`. In particular, be careful when using `skip > 0` and `randomize = TRUE`; in this case, choosing a wrong seed (or no seed) might lead to a bad sequence.

Note that these procedures call fast C code. The following restrictions apply:

korobov()

`n`,`d` must be <= 2^31-1.

ghalton()

`n` must be <= 2^32-1 and `d` must be <= 360.

sobol()

if `randomize = "none"` or ```randomize = "digital.shift"```, `n` must be <= 2^31-1 and `d` must be <= 16510.

The choice of parameters for `korobov()` is crucial for the quality of this quasi-random sequence (only basic sanity checks are conducted). For more details, see l'Ecuyer and Lemieux (2000).

The generalized Halton sequence uses the scrambling factors of Faure and Lemieux (2009).

## Value

`korobov()` and `ghalton()` return an (n,d)-`matrix`; for d=1 an n-vector is returned.

## Author(s)

Marius Hofert and Christiane Lemieux

## References

Faure, H., Lemieux, C. (2009). Generalized Halton Sequences in 2008: A Comparative Study. ACM-TOMACS 19(4), Article 15.

l'Ecuyer, P., Lemieux, C. (2000). Variance Reduction via Lattice Rules. Stochastic Models and Simulation, 1214–1235.

Lemieux, C., Cieslak, M., Luttmer, K. (2004). RandQMC User's guide. See https://www.math.uwaterloo.ca/~clemieux/randqmc/guide.pdf

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```n <- 1021 # prime d <- 4 # dimension ## Korobov's sequence generator <- 76 # see l'Ecuyer and Lemieux u <- korobov(n, d = d, generator = generator) pairs(u, gap = 0, pch = ".", labels = as.expression( sapply(1:d, function(j) bquote(italic(u[.(j)]))))) ## Randomized Korobov's sequence set.seed(271) u <- korobov(n, d = d, generator = generator, randomize = "shift") pairs(u, gap = 0, pch = ".", labels = as.expression( sapply(1:d, function(j) bquote(italic(u[.(j)]))))) ## Generalized Halton sequence (randomized by definition) set.seed(271) u <- ghalton(n, d) pairs(u, gap = 0, pch = ".", labels = as.expression( sapply(1:d, function(j) bquote(italic(u[.(j)]))))) ## For sobol() examples, see demo(sobol_examples) ```

### Example output   ```
```

qrng documentation built on Nov. 26, 2020, 5:08 p.m.