Learn R Programming

SoDA (version 1.0-6.1)

randomSlippage: Are simulated sequences robust?

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

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.

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.

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.

Examples

Run this code
# NOT RUN {
set.seed(211)
RNGkind("default", "Ahrens")
xx = randomSlippage(1000, rnorm(20), rnorm(20))
table(xx[,1], xx[,2])
# }

Run the code above in your browser using DataLab