PortableRandomInnovations {fBasics}R Documentation

Generator for Portable Random Innovations

Description

A collection and description of functions to generate portable random innovations. The functions run under R and SPlus and generate the same sequence of random numbers. Supported are uniform, normal and Student-t distributed random numbers.

The functions are:

set.lcgseed Set initial random seed,
get.lcgseed Get the current valus of the random seed,
runif.lcg Uniform linear congruational generator,
rnorm.lcg Normal linear congruational generator,
rt.lcg Student-t linear congruential generator.

Usage

set.lcgseed(seed = 4711)
get.lcgseed()
runif.lcg(n, min = 0, max = 1)
rnorm.lcg(n, mean = 0, sd = 1)
rt.lcg(n, df)   

Arguments

df number of degrees of freedom, a positive integer, maybe non-integer.
mean, sd means and standard deviation of the normal distributed innovations.
min, max lower and upper limits of the uniform distributed innovations.
seed an integer value, the random number seed.
n an integer, the number of random innovations to be generated.

Details

A simple portable random number generator for use in R and SPlus. We recommend to use this generator only for comparisons of calculations in R and Splus.

The generator is a linear congruential generator with parameters LCG(a=13445, c=0, m=2^31-1, X=0). It is a simple random number generator which passes the bitwise randomness test.

Value

A vector of generated random innovations. The value of the current seed is stored in the variable lcg.seed.

Author(s)

Diethelm Wuertz for the Rmetrics R-port.

References

Altman, N.S. (1988); Bitwise Behavior of Random Number Generators, SIAM J. Sci. Stat. Comput., 9(5), September, 941–949.

Examples

## SOURCE("fSeries.15B-PortableRandomInnovations")

## set.lcgseed -
   xmpBasics("\nStart: Set Initial Seed >")
   set.lcgseed(seed = 65890)
 
## runif.lcg - rnorm.lcg - rt.lcg -
   xmpBasics("\nNext: Create Random Numbers >")
   cbind(runif.lcg(10), rnorm.lcg(10), rt.lcg(10, df = 4))

## get.lcgseed -
   xmpBasics("\nNext: What is the current value of the seed? >")
   get.lcgseed()  
   
## Note, to overwrite rnorm, use
   # rnorm = rnorm.lcg
   # Going back to rnorm
   # rm(rnorm)

[Package fBasics version 221.10065 Index]