diff --git a/404.html b/404.html index 2a749cb..70fc187 100644 --- a/404.html +++ b/404.html @@ -32,7 +32,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/articles/cpp-api.html b/articles/cpp-api.html index 4f7759f..fcbe201 100644 --- a/articles/cpp-api.html +++ b/articles/cpp-api.html @@ -33,7 +33,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -91,7 +91,7 @@

C++ API

Ralf Stubner

-

2024-04-29

+

2024-05-12

Source: vignettes/cpp-api.Rmd @@ -265,7 +265,7 @@

Accessing the global RNG
Rcpp::XPtr<dqrng::random_64bit_generator> dqrng::get_rng()

Direct usage of this method is discouraged. The -prefered way of accesing the global RNG is to instantiate +preferred way of accessing the global RNG is to instantiate dqrng::random_64bit_accessor within your function. Note that you MUST NOT delete the global RNG. Using dqrng::random_64bit_accessor makes this impossible. In @@ -274,7 +274,7 @@

Accessing the global RNGdqrng::random_64bit_accessor SHOULD be stored as (non-static) variables in functions.

Note that dqrng::random_64bit_accessor supports UniformRandomBitGenerator -and can therefore be used together with any C++11 distribtion function. +and can therefore be used together with any C++11 distribution function. In addition, the following functions are supported, since they are inherited from the abstract parent class random_64bit_generator:

diff --git a/articles/dqrng.html b/articles/dqrng.html index 21b625d..8d451e5 100644 --- a/articles/dqrng.html +++ b/articles/dqrng.html @@ -33,7 +33,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -91,7 +91,7 @@

Fast Pseudo Random Number Generators for R

Ralf Stubner

-

2024-04-29

+

2024-05-12

Source: vignettes/dqrng.Rmd @@ -166,7 +166,7 @@

Usage from Rsystem.time(cat("pi ~= ", piR(N), "\n")) #> pi ~= 3.140899 #> user system elapsed -#> 0.426 0.032 0.457 +#> 0.378 0.029 0.406

Using dqrng is about three times faster:

 library(dqrng)
@@ -174,46 +174,46 @@ 

Usage from Rsystem.time(cat("pi ~= ", piR(N, rng = dqrng::dqrunif), "\n")) #> pi ~= 3.141457 #> user system elapsed -#> 0.206 0.020 0.228

+#> 0.174 0.036 0.209

Since the calculations add a constant off-set, the speed-up for the RNGs alone has to be even greater:

 system.time(stats::runif(N))
 #>    user  system elapsed 
-#>   0.085   0.004   0.089
+#>   0.085   0.004   0.088
 system.time(dqrng::dqrunif(N))
 #>    user  system elapsed 
-#>   0.028   0.004   0.032
+#> 0.023 0.008 0.032

Similar for the exponential distribution:

 system.time(stats::rexp(N))
 #>    user  system elapsed 
-#>   0.334   0.008   0.341
+#>   0.336   0.004   0.340
 system.time(dqrng::dqrexp(N))
 #>    user  system elapsed 
-#>   0.036   0.012   0.047
+#> 0.034 0.013 0.046

And for the normal distribution:

 system.time(stats::rnorm(N))
 #>    user  system elapsed 
-#>   0.366   0.001   0.367
+#>   0.356   0.008   0.365
 system.time(dqrng::dqrnorm(N))
 #>    user  system elapsed 
-#>   0.071   0.000   0.071
+#> 0.059 0.012 0.071

As well as for sampling with and without replacement:

 system.time(for (i in 1:100)   sample.int(N, N/100, replace = TRUE))
 #>    user  system elapsed 
-#>   0.571   0.016   0.587
+#>   0.570   0.016   0.587
 system.time(for (i in 1:100) dqsample.int(N, N/100, replace = TRUE))
 #>    user  system elapsed 
-#>   0.028   0.008   0.037
+#>   0.021   0.016   0.037
 system.time(for (i in 1:100)   sample.int(N, N/100))
 #>    user  system elapsed 
-#>   2.008   0.324   2.333
+#>   1.488   0.304   1.792
 system.time(for (i in 1:100) dqsample.int(N, N/100))
 #>    user  system elapsed 
-#>    0.04    0.02    0.06
+#> 0.055 0.004 0.059

It is also possible to register the supplied generators as user-supplied RNGs. This way set.seed() and dqset.seed() influence both (dq)runif and diff --git a/articles/index.html b/articles/index.html index decb61c..fe8c849 100644 --- a/articles/index.html +++ b/articles/index.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/articles/parallel.html b/articles/parallel.html index f27b462..d31fa57 100644 --- a/articles/parallel.html +++ b/articles/parallel.html @@ -33,7 +33,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -91,7 +91,7 @@

Parallel RNG usage

Ralf Stubner

-

2024-04-29

+

2024-05-12

Source: vignettes/parallel.Rmd @@ -252,11 +252,7 @@

PCG: multiple streams with RcppP or the two argument constructor with seed and stream. When used from R or C++ with the two argument dqset.seed -and dqset_seed you get \(2^{64}\) streams out of the possible \(2^{127}\) separate streams. Note that -here in contrast to the default PCG implementation, -streams are counted from the default stream, i.e. setting -stream to 0 or not at all will give the same -RNG. This brings PCG in line with the other RNGs.

+and dqset_seed you get \(2^{64}\) streams out of the possible \(2^{127}\) separate streams.

In the following example a matrix with random numbers is generated in parallel using RcppParallel. Instead of using the more traditional approach of generating the random numbers from a certain distribution, @@ -303,21 +299,21 @@

PCG: multiple streams with RcppP */

Head of the random matrix:

      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]
-[1,] 16583 94445 14240 53296 15021 72402 12677 47777
-[2,] 49983 29144 49983 80361 49983 60477 49983  6255
-[3,] 56598 19559 87036 76208  8804 67365 60990 22777
-[4,] 64117 18406 69814 56954 14447 27027 50950 10545
-[5,] 48709 62087 66064  2944 11887 75422  5823 48069
-[6,] 81061 71093 52958  6324 82242 68439 68331 41016
+[1,] 67984 16279 69262 7126 21441 37720 51107 51045 +[2,] 69310 21713 82885 81157 54051 5261 91165 17833 +[3,] 76742 31232 78953 4626 94939 29416 85652 78296 +[4,] 76349 47427 1770 37957 33888 59134 94591 65793 +[5,] 85008 89224 43493 7925 60866 2464 14080 10763 +[6,] 38017 88509 51195 73086 1883 68193 75259 62216

Correlation matrix:

[1,] 1              
 [2,]   1            
 [3,]   ? 1          
-[4,] ?     1        
+[4,]     ? 1        
 [5,]         1      
-[6,]     ?     1    
-[7,] ? ? ? ?   ? 1  
-[8,]   ?           1
+[6,] ? ?     ? 1    
+[7,]     ?       1  
+[8,]     ?         1
 attr(,"legend")
 [1] 0 ‘ ’ 0.001 ‘?’ 0.003 ‘!’ 0.999 ‘1’ 1

So as expected the correlation matrix is almost equal to the identity @@ -483,8 +479,8 @@

Using the global RNG2 This way, the global RNG’s state advances +as if it had processed one of the streams and successive calls to parallel_generate() produce different random numbers as expected.

@@ -539,6 +535,10 @@ 

Using the global RNG

See for example https://www.pcg-random.org/posts/critiquing-pcg-streams.html.↩︎

+
  • Note that here in contrast to the +default PCG implementation, streams are counted from the current stream, +i.e. setting stream to 0 will give the same +RNG. This brings PCG in line with the other RNGs.↩︎

  • diff --git a/articles/sample.html b/articles/sample.html index 580319f..ced8126 100644 --- a/articles/sample.html +++ b/articles/sample.html @@ -33,7 +33,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -91,7 +91,7 @@

    Fast sampling methods

    Ralf Stubner

    -

    2024-04-29

    +

    2024-05-12

    Source: vignettes/sample.Rmd diff --git a/authors.html b/authors.html index 1b6a0fa..cb53401 100644 --- a/authors.html +++ b/authors.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -114,13 +114,13 @@

    Citation

    Stubner R (2024). dqrng: Fast Pseudo Random Number Generators. -R package version 0.3.2.6, https://github.com/daqana/dqrng, https://daqana.github.io/dqrng/. +R package version 0.3.2.7, https://github.com/daqana/dqrng, https://daqana.github.io/dqrng/.

    @Manual{,
       title = {dqrng: Fast Pseudo Random Number Generators},
       author = {Ralf Stubner},
       year = {2024},
    -  note = {R package version 0.3.2.6, https://github.com/daqana/dqrng},
    +  note = {R package version 0.3.2.7, https://github.com/daqana/dqrng},
       url = {https://daqana.github.io/dqrng/},
     }
    diff --git a/index.html b/index.html index 884e513..33969b1 100644 --- a/index.html +++ b/index.html @@ -33,7 +33,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/news/index.html b/news/index.html index 6d60c6b..6eee4e0 100644 --- a/news/index.html +++ b/news/index.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/pkgdown.yml b/pkgdown.yml index faf1412..6dddf92 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -6,5 +6,5 @@ articles: dqrng: dqrng.html parallel: parallel.html sample: sample.html -last_built: 2024-04-29T11:50Z +last_built: 2024-05-12T19:23Z diff --git a/reference/dqrmv-1.png b/reference/dqrmv-1.png index e974b16..c03dcb3 100644 Binary files a/reference/dqrmv-1.png and b/reference/dqrmv-1.png differ diff --git a/reference/dqrmv.html b/reference/dqrmv.html index 0b3c1c6..0abf76f 100644 --- a/reference/dqrmv.html +++ b/reference/dqrmv.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 @@ -101,11 +101,11 @@

    Examples

    sigma <- matrix(c(4,2,2,3), ncol=2)
     x <- dqrmvnorm(n=500, mean=c(1,2), sigma=sigma)
     colMeans(x)
    -#> [1] 1.003538 1.934564
    +#> [1] 0.8763062 1.9729893
     var(x)
     #>          [,1]     [,2]
    -#> [1,] 3.491749 1.690429
    -#> [2,] 1.690429 2.765608
    +#> [1,] 3.789840 1.784189
    +#> [2,] 1.784189 3.049676
     plot(x)
     
     
    diff --git a/reference/dqrng-functions.html b/reference/dqrng-functions.html index a1bd544..7f16662 100644 --- a/reference/dqrng-functions.html +++ b/reference/dqrng-functions.html @@ -31,7 +31,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/reference/dqrng-package.html b/reference/dqrng-package.html index 346f899..027f56a 100644 --- a/reference/dqrng-package.html +++ b/reference/dqrng-package.html @@ -20,7 +20,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/reference/dqsample.html b/reference/dqsample.html index e36e5f1..47dba65 100644 --- a/reference/dqsample.html +++ b/reference/dqsample.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/reference/generateSeedVectors.html b/reference/generateSeedVectors.html index 2d70b2e..9bd490e 100644 --- a/reference/generateSeedVectors.html +++ b/reference/generateSeedVectors.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/reference/index.html b/reference/index.html index b3bf9c8..d5bbaf7 100644 --- a/reference/index.html +++ b/reference/index.html @@ -17,7 +17,7 @@ dqrng - 0.3.2.6 + 0.3.2.7 diff --git a/reference/user-supplied-rng.html b/reference/user-supplied-rng.html index 30991e9..336b305 100644 --- a/reference/user-supplied-rng.html +++ b/reference/user-supplied-rng.html @@ -19,7 +19,7 @@ dqrng - 0.3.2.6 + 0.3.2.7