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")'. > > n <- 5 > > #### outputs #### > frac <- function(x) x-floor(x) > > torusR <- function(n, k) + frac(1:n %o% sqrt(get.primes(k))) > > torusR(n, 5) - torus(n, 5) [,1] [,2] [,3] [,4] [,5] [1,] 0 0 0 0 0 [2,] 0 0 0 0 0 [3,] 0 0 0 0 0 [4,] 0 0 0 0 0 [5,] 0 0 0 0 0 > > #### n argument #### > try(torus(-1)) Error in torus(-1) : invalid argument 'n' > > #### dim argument #### > try(torus(1, 0)) Error in torus(1, 0) : invalid argument 'dim' > > #### prime argument #### > try(torus(1, prime="a")) Error in torus(1, prime = "a") : invalid argument 'prime' > torus(n, prime=5) - torus(n, 3)[,3] [1] 0 0 0 0 0 > > #### init argument #### > torus(n) [1] 0.41421356 0.82842712 0.24264069 0.65685425 0.07106781 > randtoolbox:::.getrandtoolboxEnv(".torus.seed") $offset [1] 6 > torus(n, init=TRUE) [1] 0.41421356 0.82842712 0.24264069 0.65685425 0.07106781 > randtoolbox:::.getrandtoolboxEnv(".torus.seed") $offset [1] 6 > torus(n, init=FALSE) [1] 0.4852814 0.8994949 0.3137085 0.7279221 0.1421356 > try(torus(5, init="a")) Error in torus(5, init = "a") : invalid argument 'init' > > #### mixed argument #### > > try(torus(1, mixed=3)) Error in torus(1, mixed = 3) : invalid argument 'mixed' > torus(n, mixed=TRUE) [1] 0.5042050 0.9301722 0.3437977 0.4355583 0.5185871 > > > #hybrid QMC with SFMT : test continuing the sequence (bug reported by Hiroyuki Kawakatsu) > setSeed(1234); > torus(n, init=TRUE, mixed=TRUE, mexp=607) [1] 0.7690909 0.4300909 0.9395638 0.1510878 0.8004436 > torus(n, init=FALSE, mixed=TRUE) [1] 0.6538782 0.1960783 0.1490972 0.5272617 0.6803646 > > > setSeed(1234); > torus(n, init=TRUE, mixed=TRUE, mexp=607) [1] 0.7690909 0.4300909 0.9395638 0.1510878 0.8004436 > torus(n, init=FALSE, mixed=TRUE) [1] 0.6538782 0.1960783 0.1490972 0.5272617 0.6803646 > > #### usetime argument #### > > #QMC with time machine start > torus(n, usetime=TRUE) [1] 0.62943251 0.04364607 0.45785964 0.87207320 0.28628676 > torus(n, usetime=TRUE) [1] 0.62943251 0.04364607 0.45785964 0.87207320 0.28628676 > > #### normal argument #### > torus(n, normal=TRUE) [1] -0.2167193 0.9479680 -0.6978334 0.4038929 -1.4678844 > try(torus(3, normal=1)) Error in torus(3, normal = 1) : invalid argument 'normal' > > #### mexp argument #### > torus(n, mexp=607) [1] 0.41421356 0.82842712 0.24264069 0.65685425 0.07106781 > try(torus(3, mexp=3)) Error in torus(3, mexp = 3) : 'mexp' must be in {607, 1279, 2281, 4253, 11213, 19937, 44497, 86243, 132049, 216091}. > try(torus(3, mexp="3")) Error in torus(3, mexp = "3") : invalid argument 'mexp' > > #### start argument #### > try(torus(3, start="3")) Error in torus(3, start = "3") : invalid argument 'start' > torus(n, start=0) [1] 0.0000000 0.4142136 0.8284271 0.2426407 0.6568542 > torus(n, start=1) [1] 0.41421356 0.82842712 0.24264069 0.65685425 0.07106781 > > proc.time() user system elapsed 0.17 0.09 0.26