Learn R Programming

Nmix (version 2.0.5)

sdrni: Random number initialiser, allowing retrospective replication

Description

Front-end to standard R random number seed setter, allowing retrospective replication

Usage

sdrni(seed)

Value

seed if input value is positive, otherwise the value that if used in a subsequent call will deliver exactly the same random numbers

Arguments

seed

non-negative integer random number seed, often 0 for absolute re-initialisation as with set.seed(NULL)

Author

Peter J. Green

Details

Using sdrni to initialise random number stream allows a decision to repeat a simulation exactly, presumably with additional outputs, need only be made after seeing results; see Examples

Examples

Run this code
sdrni(0)
runif(5)
keep<-sdrni(0)
runif(5)
sdrni(keep)
runif(5)

Run the code above in your browser using DataLab