R Under development (unstable) (2024-10-17 r87242 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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 an HTML browser interface to help. Type 'q()' to quit R. > library(randtoolbox) Loading required package: rngWELL This is randtoolbox. For an overview, type 'help("randtoolbox")'. > > #### outputs #### > print(halton(1, 5)) [,1] [,2] [,3] [,4] [,5] [1,] 0.5 0.3333333 0.2 0.1428571 0.09090909 > > options(digits=15) > n <- 100 > n <- 5 > cbind( 1/get.primes(n), as.vector(halton(1, n) ) ) [,1] [,2] [1,] 0.5000000000000000 0.5000000000000000 [2,] 0.3333333333333333 0.3333333333333333 [3,] 0.2000000000000000 0.2000000000000000 [4,] 0.1428571428571428 0.1428571428571428 [5,] 0.0909090909090909 0.0909090909090909 > > #### n argument #### > try(halton(-1)) Error in halton(-1) : invalid argument 'n' > > #### dim argument #### > try(halton(1, 0)) Error in halton(1, 0) : invalid argument 'dim' > > > #### init argument #### > halton(n) [1] 0.500 0.250 0.750 0.125 0.625 > randtoolbox:::.getrandtoolboxEnv(".halton.seed") $base [1] 2 $offset [1] 6 > halton(n, init=TRUE) [1] 0.500 0.250 0.750 0.125 0.625 > randtoolbox:::.getrandtoolboxEnv(".halton.seed") $base [1] 2 $offset [1] 6 > halton(n, init=FALSE) [1] 0.3750 0.8750 0.0625 0.5625 0.3125 > try(halton(5, init="a")) Error in halton(5, init = "a") : invalid argument 'init' > > #### mixed argument #### > > try(halton(1, mixed=3)) Error in halton(1, mixed = 3) : invalid argument 'mixed' > halton(n, mixed=TRUE) [1] 0.102862385101616 0.313063856214285 0.286233811639249 0.392372249159962 [5] 0.701482330216095 > > #### usetime argument #### > #QMC with time machine start > halton(n, usetime=TRUE) [1] 0.914627075195312 0.102127075195312 0.602127075195312 0.352127075195312 [5] 0.852127075195312 > halton(n, usetime=TRUE) [1] 0.914627075195312 0.102127075195312 0.602127075195312 0.352127075195312 [5] 0.852127075195312 > > #hybrid QMC with SFMT : test continuing the sequence (bug reported by Hiroyuki Kawakatsu) > setSeed(1234); > halton(n, init=TRUE, mixed=TRUE, mexp=607) [1] 0.7717277337796986 0.2175991137046367 0.0579174996819347 0.9341774594504386 [5] 0.7164084406103939 > halton(n, init=FALSE, mixed=TRUE) [1] 0.296885532094166 0.920652552042156 0.437001249287277 0.144013730110601 [5] 0.131321514490992 > > setSeed(1234); > halton(n, init=TRUE, mixed=TRUE, mexp=607) [1] 0.7717277337796986 0.2175991137046367 0.0579174996819347 0.9341774594504386 [5] 0.7164084406103939 > halton(n, init=FALSE, mixed=TRUE) [1] 0.296885532094166 0.920652552042156 0.437001249287277 0.144013730110601 [5] 0.131321514490992 > > #### method argument #### > n <- 5 > d <- 4 > halton(n, d, method="C") [,1] [,2] [,3] [,4] [1,] 0.500 0.333333333333333 0.20 0.142857142857143 [2,] 0.250 0.666666666666667 0.40 0.285714285714286 [3,] 0.750 0.111111111111111 0.60 0.428571428571429 [4,] 0.125 0.444444444444444 0.80 0.571428571428571 [5,] 0.625 0.777777777777778 0.04 0.714285714285714 > randtoolbox:::.getrandtoolboxEnv(".halton.seed") $base [1] 2 3 5 7 $offset [1] 6 > halton(n, d, method="C", start=5) [,1] [,2] [,3] [,4] [1,] 0.6250 0.777777777777778 0.04 0.7142857142857142 [2,] 0.3750 0.222222222222222 0.24 0.8571428571428571 [3,] 0.8750 0.555555555555556 0.44 0.0204081632653061 [4,] 0.0625 0.888888888888889 0.64 0.1632653061224490 [5,] 0.5625 0.037037037037037 0.84 0.3061224489795918 > > #### normal argument #### > halton(n, normal=TRUE) [1] 0.000000000000000 -0.674489750196082 0.674489750196082 -1.150349380376008 [5] 0.318639363964375 > try(halton(3, normal=1)) Error in halton(3, normal = 1) : invalid argument 'normal' > > #### mexp argument #### > halton(n, mexp=607) [1] 0.500 0.250 0.750 0.125 0.625 > try(halton(3, mexp=3)) Error in halton(3, mexp = 3) : 'mexp' must be in {607, 1279, 2281, 4253, 11213, 19937, 44497, 86243, 132049, 216091}. > try(halton(3, mexp="3")) Error in halton(3, mexp = "3") : invalid argument 'mexp' > > > #### start argument #### > try(halton(3, start="3")) Error in halton(3, start = "3") : invalid argument 'start' > halton(n, start=0) [1] 0.000 0.500 0.250 0.750 0.125 > halton(n, start=1) [1] 0.500 0.250 0.750 0.125 0.625 > > > proc.time() user system elapsed 0.15 0.09 0.23