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("rlecuyer-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('rlecuyer') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "CreateStream" > > ### * CreateStream > > flush(stderr()); flush(stdout()) > > ### Name: CreateStream > ### Title: Spawn new streams > ### Aliases: .lec.CreateStream > ### Keywords: distribution > > ### ** Examples > > nstreams <- 10 # number of streams > names <- paste("mystream",1:nstreams,sep="") > .lec.CreateStream(names) > .lec.WriteStateFull(names) [1] The Rngstream mystream1: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 12345 12345 12345 12345 12345 12345 [1] Bg = 12345 12345 12345 12345 12345 12345 [1] Cg = 12345 12345 12345 12345 12345 12345 [1] The Rngstream mystream2: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 3692455944 1366884236 2968912127 335948734 4161675175 475798818 [1] Bg = 3692455944 1366884236 2968912127 335948734 4161675175 475798818 [1] Cg = 3692455944 1366884236 2968912127 335948734 4161675175 475798818 [1] The Rngstream mystream3: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 1015873554 1310354410 2249465273 994084013 2912484720 3876682925 [1] Bg = 1015873554 1310354410 2249465273 994084013 2912484720 3876682925 [1] Cg = 1015873554 1310354410 2249465273 994084013 2912484720 3876682925 [1] The Rngstream mystream4: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 2338701263 1119171942 2570676563 317077452 3194180850 618832124 [1] Bg = 2338701263 1119171942 2570676563 317077452 3194180850 618832124 [1] Cg = 2338701263 1119171942 2570676563 317077452 3194180850 618832124 [1] The Rngstream mystream5: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 1597262096 3906379055 3312112953 1016013135 4099474108 275305423 [1] Bg = 1597262096 3906379055 3312112953 1016013135 4099474108 275305423 [1] Cg = 1597262096 3906379055 3312112953 1016013135 4099474108 275305423 [1] The Rngstream mystream6: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 97147054 3131372450 829345164 3691032523 3006063034 4259826321 [1] Bg = 97147054 3131372450 829345164 3691032523 3006063034 4259826321 [1] Cg = 97147054 3131372450 829345164 3691032523 3006063034 4259826321 [1] The Rngstream mystream7: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 796079799 2105258207 955365076 2923159030 4116632677 3067683584 [1] Bg = 796079799 2105258207 955365076 2923159030 4116632677 3067683584 [1] Cg = 796079799 2105258207 955365076 2923159030 4116632677 3067683584 [1] The Rngstream mystream8: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 3281794178 2616230133 1457051261 2762791137 2480527362 2282316169 [1] Bg = 3281794178 2616230133 1457051261 2762791137 2480527362 2282316169 [1] Cg = 3281794178 2616230133 1457051261 2762791137 2480527362 2282316169 [1] The Rngstream mystream9: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 3777646647 1837464056 4204654757 664239048 4190510072 2959195122 [1] Bg = 3777646647 1837464056 4204654757 664239048 4190510072 2959195122 [1] Cg = 3777646647 1837464056 4204654757 664239048 4190510072 2959195122 [1] The Rngstream mystream10: [1] Anti = 0 [1] IncPrec = 0 [1] Ig = 4215590817 3862461878 1087200967 1544910132 936383720 1611370123 [1] Bg = 4215590817 3862461878 1087200967 1544910132 936383720 1611370123 [1] Cg = 4215590817 3862461878 1087200967 1544910132 936383720 1611370123 > > > > cleanEx(); ..nameEx <- "CurrentStream" > > ### * CurrentStream > > flush(stderr()); flush(stdout()) > > ### Name: CurrentStream > ### Title: Set/unset the current stream > ### Aliases: .lec.CurrentStream .lec.CurrentStreamEnd > ### Keywords: distribution > > ### ** Examples > > nstreams <- 10 # number of streams > names <- paste("mystream",1:nstreams,sep="") > .lec.CreateStream(names) > for (i in 1:nstreams) { # generate 10 RNs from each stream + .lec.CurrentStream(names[i]) + print(paste("stream no.",i)) + print(runif(10)) + .lec.CurrentStreamEnd() + } [1] "stream no. 1" [1] 0.92874648 0.10583246 0.45764757 0.32257992 0.02141915 0.82041297 [7] 0.62595586 0.89997622 0.94401091 0.63874310 [1] "stream no. 2" [1] 0.404547168 0.005985393 0.629442858 0.486461829 0.571567844 0.107630898 [7] 0.067577131 0.621707447 0.177325756 0.611446405 [1] "stream no. 3" [1] 0.95756180 0.09600628 0.09794506 0.64013684 0.37688207 0.71320484 [7] 0.47335977 0.86389555 0.39450917 0.13434102 [1] "stream no. 4" [1] 0.08196407 0.67388213 0.41543928 0.49042872 0.67294595 0.33815244 [7] 0.40909426 0.97256140 0.60227381 0.55922926 [1] "stream no. 5" [1] 0.06037399 0.20826659 0.10314791 0.09759640 0.73671694 0.89508698 [7] 0.35866262 0.42792170 0.94394348 0.83637659 [1] "stream no. 6" [1] 0.97082230 0.89700603 0.54417097 0.60293170 0.63312922 0.01528112 [7] 0.98613256 0.51217371 0.09314834 0.39069873 [1] "stream no. 7" [1] 0.39585475 0.39944337 0.86126725 0.50423011 0.46359206 0.46327695 [7] 0.03516136 0.72159808 0.51055170 0.60054891 [1] "stream no. 8" [1] 0.97374954 0.25074347 0.39762598 0.01359972 0.02647024 0.91857160 [7] 0.01441393 0.78255141 0.16714024 0.87398736 [1] "stream no. 9" [1] 0.91028305 0.20877556 0.41173237 0.45438220 0.32033781 0.79890455 [7] 0.07022456 0.64755439 0.64020276 0.48170345 [1] "stream no. 10" [1] 0.55604796 0.97478247 0.76513550 0.06704131 0.45285396 0.87949045 [7] 0.69613405 0.50737178 0.87150771 0.99856793 > > > > cleanEx(); ..nameEx <- "uniform" > > ### * uniform > > flush(stderr()); flush(stdout()) > > ### Name: uniform > ### Title: Generate random numbers > ### Aliases: .lec.uniform .lec.uniform.int > ### Keywords: distribution > > ### ** Examples > > nstreams <- 10 # number of streams > seed<-rep(1,6) > .lec.SetPackageSeed(seed) [1] 1 1 1 1 1 1 > names <- paste("mystream",1:nstreams,sep="") > .lec.CreateStream(names) > for (i in 1:nstreams) # generate 10 RNs from each stream + print(.lec.uniform(names[i],10)) [1] 0.0003395772 0.5558807160 0.0142046607 0.0881226713 0.4411733820 [6] 0.7991554535 0.3129617716 0.8164760514 0.2346017519 0.6388651433 [1] 0.16644823 0.82381720 0.75445447 0.53854099 0.26967246 0.06088786 [7] 0.81342873 0.45647629 0.27758519 0.01979045 [1] 0.40953779 0.19805827 0.86853361 0.56841918 0.64657563 0.90668672 [7] 0.15669687 0.06503323 0.10323087 0.33794767 [1] 0.1473558 0.8921580 0.8659602 0.1710683 0.5729402 0.2041932 0.7582495 [8] 0.5783814 0.1698808 0.4933208 [1] 0.9170475 0.7046074 0.8707009 0.3082317 0.9336580 0.7457962 0.4804126 [8] 0.2772204 0.9140097 0.2832278 [1] 0.634454068 0.852744999 0.006132466 0.735465643 0.542085787 0.055688283 [7] 0.626208875 0.656744698 0.478900680 0.920568701 [1] 0.37367351 0.08135017 0.27044390 0.42420094 0.18843716 0.20690125 [7] 0.30373641 0.03298780 0.60379127 0.14428779 [1] 0.069244756 0.001837285 0.030587501 0.622354055 0.049580785 0.545481241 [7] 0.286665477 0.829309228 0.706257205 0.212599694 [1] 0.3227408 0.7074169 0.8153675 0.3631263 0.2484977 0.5835658 0.5306508 [8] 0.1169660 0.4276150 0.6320671 [1] 0.3237190 0.3253448 0.1864128 0.1318845 0.4550973 0.3438756 0.5303345 [8] 0.6139807 0.5200416 0.7731785 > .lec.DeleteStream(names) > > > > ### *