diff --git a/404.html b/404.html index 2a749cb..70fc187 100644 --- a/404.html +++ b/404.html @@ -32,7 +32,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 @@ @@ -91,7 +91,7 @@vignettes/cpp-api.Rmd
cpp-api.Rmd
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 @@
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
:
vignettes/dqrng.Rmd
dqrng.Rmd
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
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
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
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
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
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 @@
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 @@
@@ -91,7 +91,7 @@
vignettes/parallel.Rmd
parallel.Rmd
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 @@
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 @@
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
to0
will give the same +RNG. This brings PCG in line with the other RNGs.↩︎
vignettes/sample.Rmd
sample.Rmd
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 @@ 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 @@ 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 @@ @@ -101,11 +101,11 @@