# perturbations: Generate Random Variates from a Perturbed RVG In rvgtest: Tools for Analyzing Non-Uniform Pseudo-Random Variate Generators

## Description

These functions perturb the distribution of a given random variate generator. Thus it allows to investigate the power of tests for random variate generators.

## Usage

 ```1 2``` ```pertadd(n, rdist = rnorm, ..., min = 0, max = 1, p = 0.001) pertsub(n, rdist = rnorm, ..., min = 0, max = 1, p = 0.001) ```

## Arguments

 `n` sample size. `rdist` given RVG to be perturbed. `...` parameters for given random variate generator. `min, max` left and right boundary of perturbed domain. `p` strength of perturbation.

## Details

`pertadd` generates random variates from a mixture of `rdist` and a uniform distribution on the interval (`min`,`max`). The uniform distribution is chosen with probability `p`.

`pertsub` generates random variates from the `rdist` but rejects all points in the interval (`min`,`max`) with probability `p`.

By varying the width of uniform distribution (`min`,`max`) and probability of error `p`, different levels of “artificial” error can be introduced. Thus it allows to investigate the power of tests for random variate generators.

## Value

A vector of random variates from the perturbed distribution is returned.

## Author(s)

Sougata Chaudhuri [email protected], Josef Leydold [email protected]

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```## Generating random sample with default settings x <- pertadd(n=1000) y <- pertsub(n=1000) ## Generating random sample, with parent distribution as exponential. x <- pertadd(n=1000, rdist=rexp, rate=2, min=2, max=3, p=0.005) y <- pertsub(n=1000, rdist=rexp, rate=2, min=2, max=3, p=0.005) ## Conducting chi-square test on random variates generated from function ## pertsub with parent distribution as exponential. ft <- rvgt.ftable(n=1e4,rep=10, rdist=function(n){pertsub(n,rdist=rexp,p=0.1)}, qdist=qexp,breaks=1001) plot(ft) rvgt.chisq(ft) ## Conducting chi-square test on random variates generated from function ## pertadd with parent distribution as Weibull,shape=1,scale=2. ft <- rvgt.ftable(n=1e4,rep=10, rdist=function(n,...){pertadd(n,rdist=rweibull,...,p=0.05)}, qdist=qweibull,shape=1,scale=2) plot(ft) rvgt.chisq(ft) ```

rvgtest documentation built on May 29, 2017, 9:11 a.m.