R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("rstream-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('rstream') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "rstream.RNG" > > ### * rstream.RNG > > flush(stderr()); flush(stdout()) > > ### Name: rstream.RNG > ### Title: Get and set "rstream" object from/to R global generator > ### Aliases: rstream.RNG > ### Keywords: methods > > ### ** Examples > > ## create a new rstream.runif object > s <- new("rstream.lecuyer") > > ## use this stream as global R uniform RNG > rstream.RNG(s) > > ## get a (idenpendent) copy of the stream > ## that contains the global R uniform RNG > gs <- rstream.RNG() > > ## change the state of the global generator > gs <- rstream.RNG() > rstream.nextsubstream(gs) > rstream.RNG(gs) > > > > > cleanEx(); ..nameEx <- "rstream.antithetic-methods" > > ### * rstream.antithetic-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.antithetic-methods > ### Title: Methods for Function rstream.antithetic in Package `rstream' > ### Aliases: rstream.antithetic rstream.antithetic<- > ### rstream.antithetic-methods rstream.antithetic<--methods > ### rstream.antithetic,rstream-method rstream.antithetic<-,rstream-method > ### rstream.antithetic,rstream.lecuyer-method > ### rstream.antithetic<-,rstream.lecuyer-method > ### rstream.antithetic,rstream.runif-method > ### rstream.antithetic<-,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## set antithetic flag of rstream object > rstream.antithetic(s) <- TRUE > > ## get antithetic flag of rstream object > rstream.antithetic(s) [1] TRUE > > > > > cleanEx(); ..nameEx <- "rstream.clone-methods" > > ### * rstream.clone-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.clone-methods > ### Title: Methods for Function rstream.clone in Package `rstream' > ### Aliases: rstream.clone rstream.clone-methods > ### rstream.clone,rstream-method rstream.clone,rstream.lecuyer-method > ### rstream.clone,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## make a copy (clone) > clone <- rstream.clone(s) > > > > cleanEx(); ..nameEx <- "rstream.incprecision-methods" > > ### * rstream.incprecision-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.incprecision-methods > ### Title: Methods for Function rstream.incprecision in Package `rstream' > ### Aliases: rstream.incprecision rstream.incprecision<- > ### rstream.incprecision-methods rstream.incprecision<--methods > ### rstream.incprecision,rstream-method > ### rstream.incprecision<-,rstream-method > ### rstream.incprecision,rstream.lecuyer-method > ### rstream.incprecision<-,rstream.lecuyer-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## set increased precision flag of rstream object > rstream.incprecision(s) <- TRUE > > ## get increased precision flag of rstream object > rstream.incprecision(s) [1] TRUE > > > > > cleanEx(); ..nameEx <- "rstream.lecuyer-class" > > ### * rstream.lecuyer-class > > flush(stderr()); flush(stdout()) > > ### Name: rstream.lecuyer-class > ### Title: Class "rstream.lecuyer" - Multiple streams from Pierre L'Ecuyers > ### RngStreams package > ### Aliases: rstream.lecuyer-class initialize,rstream.lecuyer-method > ### print,rstream.lecuyer-method > ### Keywords: classes > > ### ** Examples > > ## create a new rstream.lecuyer object > s <- new("rstream.lecuyer") > > ## show state of this object > print(s) Object is random stream type = rstream.lecuyer [lecuyer: RngStreams - library for multiple independent streams of Random Numbers] name = "lecuyer7" antithetic = FALSE increased Precision = FALSE Internal state: initial state: 1769227935 574954846 2550641529 3690750325 2467531316 4225987159 starting point of current substream: 1769227935 574954846 2550641529 3690750325 2467531316 4225987159 current state: 1769227935 574954846 2550641529 3690750325 2467531316 4225987159 > > ## show and change name of stream object > rstream.name(s) [1] "lecuyer7" > rstream.name(s) <- "mystream" > > ## get a random number > x <- rstream.sample(s) > > ## get a random sample of size 100 > x <- rstream.sample(s,100) > > ## reset random stream > rstream.reset(s) > > ## show and set antithetic flag > rstream.antithetic(s) [1] FALSE > rstream.antithetic(s) <- TRUE > > ## jump to next substream > rstream.nextsubstream(s) > > ## make a clone of the rstream object > sc <- rstream.clone(s) > > ## pack and unpack the rstream object > rstream.packed(s) <- TRUE > rstream.packed(s) <- FALSE > > > > > cleanEx(); ..nameEx <- "rstream.name-methods" > > ### * rstream.name-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.name-methods > ### Title: Methods for Function rstream.name in Package `rstream' > ### Aliases: rstream.name rstream.name<- rstream.name-methods > ### rstream.name<--methods rstream.name,rstream-method > ### rstream.name<-,rstream-method rstream.name,rstream.lecuyer-method > ### rstream.name<-,rstream.lecuyer-method > ### rstream.name,rstream.runif-method rstream.name<-,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## set name of rstream object > rstream.name(s) <- "mystream" > > ## get name of rstream object > rstream.name(s) [1] "mystream" > > > > > cleanEx(); ..nameEx <- "rstream.packed-methods" > > ### * rstream.packed-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.packed-methods > ### Title: Methods for Function rstream.packed in Package `rstream' > ### Aliases: rstream.packed rstream.packed<- rstream.packed-methods > ### rstream.packed<--methods rstream.packed,rstream-method > ### rstream.packed<-,rstream-method rstream.packed,rstream.lecuyer-method > ### rstream.packed<-,rstream.lecuyer-method > ### rstream.packed,rstream.runif-method > ### rstream.packed<-,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## pack rstream object > rstream.packed(s) <- TRUE > > ## status of object > rstream.packed(s) [1] TRUE > > ## pack rstream object > rstream.packed(s) <- FALSE > > > > > cleanEx(); ..nameEx <- "rstream.reset-methods" > > ### * rstream.reset-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.reset-methods > ### Title: Methods for Function rstream.reset in Package `rstream' > ### Aliases: rstream.reset rstream.reset-methods > ### rstream.reset,rstream-method rstream.reset,rstream.lecuyer-method > ### rstream.reset,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## generate a sample > x <- rstream.sample(s,10) > > ## reset the stream object > rstream.reset(s) > > ## the new sample y is identical to x > y <- rstream.sample(s,10) > if (identical(x,y)) print("x and y are identical samples") [1] "x and y are identical samples" > > > > > cleanEx(); ..nameEx <- "rstream.runif-class" > > ### * rstream.runif-class > > flush(stderr()); flush(stdout()) > > ### Name: rstream.runif-class > ### Title: Class "rstream.runif" - Interface to R internal uniform random > ### number generators > ### Aliases: rstream.runif-class initialize,rstream.runif-method > ### print,rstream.runif-method > ### Keywords: classes > > ### ** Examples > > ## create a new rstream.runif object > s <- new("rstream.runif") > > ## show state of this object > print(s) Object is random stream type = rstream.runif [runif: R uniform random number generator] name = "runif11" antithetic = FALSE increased Precision = FALSE RNGkind = Mersenne-Twister > > ## show and change name of stream object > rstream.name(s) [1] "runif11" > rstream.name(s) <- "mystream" > > ## get a random number > x <- rstream.sample(s) > > ## get a random sample of size 100 > x <- rstream.sample(s,100) > > ## reset random stream > rstream.reset(s) > > ## show and set antithetic flag > rstream.antithetic(s) [1] FALSE > rstream.antithetic(s) <- TRUE > > ## make a clone of the rstream object > sc <- rstream.clone(s) > > ## pack and unpack the rstream object > rstream.packed(s) <- TRUE > rstream.packed(s) <- FALSE > > > > > cleanEx(); ..nameEx <- "rstream.sample-methods" > > ### * rstream.sample-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.sample-methods > ### Title: Methods for Function rstream.sample in Package `rstream' > ### Aliases: rstream.sample r rstream.sample-methods r-methods > ### rstream.sample,rstream-method rstream.sample,rstream,numeric-method > ### r,rstream-method r,rstream,numeric-method > ### rstream.sample,rstream.lecuyer-method r,rstream.lecuyer-method > ### rstream.sample,rstream.runif-method r,rstream.runif-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## get a random number > x <- rstream.sample(s) > > ## get a random sample of size 100 > x <- rstream.sample(s,100) > > ## alternatively ... > x <- r(s,100) > > > > > cleanEx(); ..nameEx <- "rstream.substream-methods" > > ### * rstream.substream-methods > > flush(stderr()); flush(stdout()) > > ### Name: rstream.resetsubstream-methods > ### Title: Methods for Function rstream.resetsubstream and > ### rstream.nextsubstream in Package `rstream' > ### Aliases: rstream.resetsubstream rstream.nextsubstream > ### rstream.resetsubstream-methods rstream.nextsubstream-methods > ### rstream.resetsubstream,rstream-method > ### rstream.nextsubstream,rstream-method > ### rstream.resetsubstream,rstream.lecuyer-method > ### rstream.nextsubstream,rstream.lecuyer-method > ### Keywords: methods > > ### ** Examples > > ## create a new rstream object (of subclass rstream.lecuyer) > s <- new("rstream.lecuyer") > > ## jump to beginning of next substream > rstream.nextsubstream(s) > > ## generate a sample > x <- rstream.sample(s,10) > > ## reset substream > rstream.resetsubstream(s) > > ## the new sample y is identical to x > y <- rstream.sample(s,10) > if (identical(x,y)) print("x and y are identical samples") [1] "x and y are identical samples" > > > > > ### *