Rev 31 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{Random}\title{Random Number Generation}\usage{.Random.seed <- c(n1,n2,n3)}\alias{.Random.seed}\description{\code{.Random.seed} is an integer vector of length 3, containingthe ``seed'' for all random number generation in R.The Wichmann-Hill generator is used which has a cycle length of 6.9536e12(= \code{prod(p-1)/4} where \code{p} is the length 3 vector of primes, below),see p.123 of Applied Statistics (1984) vol.33 which corrects the originalarticle.}\value{\code{.Random.seed == r[1:3]}, where \code{r[i]} is in \code{1:p[i]},and \code{p = (30269, 30307, 30323)}.}\references{B.A. Wichmann and I. D. Hill (1982).\emph{Algorithm AS 183: An Efficient and Portable Pseudo-random NumberGenerator}, Applied Statistics, \textbf{31}, 188-190; Remarks: \textbf{34},p.198and \textbf{35}, p.89.A. De Matteis and S. Pagnutti (1993). \emph{Long-range CorrelationAnalysis of the Wichmann-Hill Random Number Generator}, Statist. Comput.,\textbf{3}, 67-70.}\note{Initially, there is no seed; a new one is created, using "Randomize".Hence, student exercises will each have different simulation results, bydefault.}\seealso{\code{\link{runif}}, \code{\link{rnorm}}, \ldots.}\examples{runif(1); .Random.seed; runif(1); .Random.seed# If there is no seed, a ``random'' new one is created:rm(.Random.seed); runif(1); .Random.seedp.WH <- c(30269, 30307, 30323)a.WH <- c( 171, 172, 170)R.seed <- function(i.seed = .Random.seed) (a.WH * i.seed) \%\% p.WHmy.runif1 <- function(i.seed = .Random.seed){ ns <- R.seed(i.seed); sum(ns / p.WH) \%\% 1 }##- This shows how 'runif(.)' works, just using R - functions :rs <- .Random.seedR.seed(rs); u <- runif(1); .Random.seed; c(u, my.runif1(rs))}