randomSlippage: Are simulated sequences robust?

Description Usage Arguments Details Value Examples

View source: R/randomSlippage.R

Description

This function inserts a specified number of extra random uniforms into a sequence of calls to a generator, and checks whether the subsequent samples re-synchronize.

Usage

1
randomSlippage(nRuns, expr1, expr2, slip = runif(1), check = FALSE)

Arguments

nRuns

Number of runs for the comparison.

expr1, expr2

The literal expressions to be evaluated before and after the possible slippage.

slip

The expression to be evaluated to cause the slippage; default runif(1).

check

If TRUE, the function will check that synchronization really did occur.

Details

The second generated result from evaluatging expr2 will resynchronize, if ever, after some number of values generated in the original and perturbed sequence, say k1 and k2. At this point, each sequence returns exactly the same value because each has used the same number of uniforms; from that point on the sequences will be identical.

Re-synchronization need never occur; see the example in the reference.

Value

The function returns a matrix with nRuns rows and two columns. For each row, the returned value is the slippages, c(k1, k2) in the Details.

Examples

1
2
3
4
set.seed(211)
RNGkind("default", "Ahrens")
xx = randomSlippage(1000, rnorm(20), rnorm(20))
table(xx[,1], xx[,2])

SoDA documentation built on Oct. 28, 2020, 9:07 a.m.