From fb96b1eaee55b277494f3cdab07cce470fe216c7 Mon Sep 17 00:00:00 2001 From: benyamindsmith Date: Sun, 27 Oct 2024 23:56:29 -0400 Subject: [PATCH] adding vingette --- .gitignore | 1 + DESCRIPTION | 4 + README.md | 11 ++ docs/404.html | 12 ++ docs/articles/index.html | 77 ++++++++++++ docs/articles/understanding-prngs.html | 164 +++++++++++++++++++++++++ docs/authors.html | 10 ++ docs/index.html | 18 +++ docs/pkgdown.yml | 5 +- docs/reference/blumb_blumb_shub.html | 10 ++ docs/reference/cmwc.html | 10 ++ docs/reference/icg.html | 10 ++ docs/reference/index.html | 10 ++ docs/reference/lcg.html | 10 ++ docs/reference/lcg_parkmiller.html | 10 ++ docs/reference/lfg.html | 10 ++ docs/reference/lfsr_fib.html | 10 ++ docs/reference/lfsr_galois.html | 10 ++ docs/reference/lfsr_xorshift.html | 10 ++ docs/reference/middlesquare.html | 10 ++ docs/reference/mwc.html | 10 ++ docs/reference/winchmann_hill.html | 10 ++ docs/sitemap.xml | 6 + vignettes/.gitignore | 2 + vignettes/understanding-prngs.Rmd | 53 ++++++++ 25 files changed, 491 insertions(+), 2 deletions(-) create mode 100644 docs/articles/index.html create mode 100644 docs/articles/understanding-prngs.html create mode 100644 vignettes/.gitignore create mode 100644 vignettes/understanding-prngs.Rmd diff --git a/.gitignore b/.gitignore index 5b6a065..c833a2c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .Rhistory .RData .Ruserdata +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 999a09e..361ebde 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,3 +11,7 @@ LazyData: true LinkingTo: Rcpp Imports: Rcpp RoxygenNote: 7.2.3 +Suggests: + knitr, + rmarkdown +VignetteBuilder: knitr diff --git a/README.md b/README.md index 6e3eb9c..d50aa4c 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,15 @@ The following is a list of supported random number generators in this package. - [ ] Squares RNG [NOT STARTED] +- [ ] L'Ecuyer-CMRG [NOT STARTED] + +- [ ] Marsaglia-Multicarry [NOT STARTED] + +- [ ] Knuth-TAOCP-2002 [NOT STARTED] + +- [ ] Knuth-TAOCP [NOT STARTED + + ## Contributing Since this project is very much in its infancy, there is alot of opportunity to contribute! Some areas include @@ -99,6 +108,8 @@ After building out a significant amount of random number generators and doing th ## Similar Packages and Inspiration +- [The `PRNG` R package](https://cran.r-project.org/web/packages/PRNG/PRNG.pdf) + - [The `random` C++ library](https://en.cppreference.com/w/cpp/numeric/random) - [PyRandLib](https://github.com/schmouk/PyRandLib) diff --git a/docs/404.html b/docs/404.html index 37c2c6c..5ee3213 100644 --- a/docs/404.html +++ b/docs/404.html @@ -47,6 +47,18 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html new file mode 100644 index 0000000..5e8ae62 --- /dev/null +++ b/docs/articles/index.html @@ -0,0 +1,77 @@ + +Articles • randngen + + +
+
+ + + +
+
+ + +
+

All vignettes

+

+ +
Why use randngen
+
+
+
+
+ + +
+ +
+

Site built with pkgdown 2.0.7.

+
+ +
+ + + + + + + + diff --git a/docs/articles/understanding-prngs.html b/docs/articles/understanding-prngs.html new file mode 100644 index 0000000..0c26aef --- /dev/null +++ b/docs/articles/understanding-prngs.html @@ -0,0 +1,164 @@ + + + + + + + +Why use randngen • randngen + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+
+ + + + +
+

Introduction +

+

Pseudo-random number generators power power much of what goes on +“behind the scenes” in statistical and cryptographic settings. In +R, there is a pseudo-random number generator present which +allows users to generate random variables from a variety of +distributions. To check the default PRNG used by your R +version you can run the following:

+
+# Using version 4.2.2 (at time of writing)
+
+RNGkind()
+#> [1] "Mersenne-Twister" "Inversion"        "Rejection"
+

The PRNG which R utilizes can be specified by specifying a +.Random.seed argument in the beginning of the R script or +by adjusting the default kind (and normal.kind +and sample.kind) arguments in the RNGkind or +set.seed argument.

+

While it is possible for one to utilize their own PRNG through use of +user-supplied random number generation, such an approach is +pedagogically complex and for users interested in working with random +number generation and still leaves abstraction around how random numbers +are generated from the seed and parameters supplied.

+ + +
+
+

References +

+
    +
  1. Random function - RDocumentation. https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Random.

  2. +
  3. Morris, T. P., White, I. R. & Crowther, M. J. Using +simulation studies to evaluate statistical methods. Statistics in +Medicine 38, 2074–2102 (2019).

  4. +
  5. Generating distributions from random number generators. Cross +Validated https://stats.stackexchange.com/questions/637706/generating-distributions-from-random-number-generators.

  6. +
  7. L’Ecuyer, P. & Simard, R. TestU01. ACM Transactions on +Mathematical Software 33, 1–40 (2007).

  8. +
+
+
+ + + +
+ + + +
+ +
+

+

Site built with pkgdown 2.0.7.

+
+ +
+
+ + + + + + + + diff --git a/docs/authors.html b/docs/authors.html index 5bdc714..5c1fa03 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -25,6 +25,16 @@ diff --git a/docs/index.html b/docs/index.html index 3de04cc..68b42c5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -48,6 +48,18 @@ @@ -116,6 +128,10 @@

Random Number Genera
  • +
  • +
  • +
  • +
  • @@ -139,6 +155,8 @@

    Future WorkSimilar Packages and Inspiration

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 42fea88..c1d6751 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,7 @@ pandoc: 3.1.11 pkgdown: 2.0.7 pkgdown_sha: ~ -articles: {} -last_built: 2024-10-23T04:31Z +articles: + understanding-prngs: understanding-prngs.html +last_built: 2024-10-28T03:55Z diff --git a/docs/reference/blumb_blumb_shub.html b/docs/reference/blumb_blumb_shub.html index ce72d37..05b6498 100644 --- a/docs/reference/blumb_blumb_shub.html +++ b/docs/reference/blumb_blumb_shub.html @@ -27,6 +27,16 @@
    diff --git a/docs/reference/cmwc.html b/docs/reference/cmwc.html index cc17852..a19b829 100644 --- a/docs/reference/cmwc.html +++ b/docs/reference/cmwc.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/icg.html b/docs/reference/icg.html index 0dcd642..ad00169 100644 --- a/docs/reference/icg.html +++ b/docs/reference/icg.html @@ -32,6 +32,16 @@ diff --git a/docs/reference/index.html b/docs/reference/index.html index 0a8aaee..0a0efb9 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/lcg.html b/docs/reference/lcg.html index a1d63b8..5cfc632 100644 --- a/docs/reference/lcg.html +++ b/docs/reference/lcg.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/lcg_parkmiller.html b/docs/reference/lcg_parkmiller.html index e1eacdd..f3d4449 100644 --- a/docs/reference/lcg_parkmiller.html +++ b/docs/reference/lcg_parkmiller.html @@ -27,6 +27,16 @@ diff --git a/docs/reference/lfg.html b/docs/reference/lfg.html index a4985f0..b38fd34 100644 --- a/docs/reference/lfg.html +++ b/docs/reference/lfg.html @@ -30,6 +30,16 @@ diff --git a/docs/reference/lfsr_fib.html b/docs/reference/lfsr_fib.html index 9801864..ff81cce 100644 --- a/docs/reference/lfsr_fib.html +++ b/docs/reference/lfsr_fib.html @@ -26,6 +26,16 @@ diff --git a/docs/reference/lfsr_galois.html b/docs/reference/lfsr_galois.html index 5932369..9f21b70 100644 --- a/docs/reference/lfsr_galois.html +++ b/docs/reference/lfsr_galois.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/lfsr_xorshift.html b/docs/reference/lfsr_xorshift.html index 9d23175..8c15723 100644 --- a/docs/reference/lfsr_xorshift.html +++ b/docs/reference/lfsr_xorshift.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/middlesquare.html b/docs/reference/middlesquare.html index 4773064..e0dfd14 100644 --- a/docs/reference/middlesquare.html +++ b/docs/reference/middlesquare.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/mwc.html b/docs/reference/mwc.html index a8871bb..87db9c6 100644 --- a/docs/reference/mwc.html +++ b/docs/reference/mwc.html @@ -25,6 +25,16 @@ diff --git a/docs/reference/winchmann_hill.html b/docs/reference/winchmann_hill.html index 317da01..c96f13b 100644 --- a/docs/reference/winchmann_hill.html +++ b/docs/reference/winchmann_hill.html @@ -25,6 +25,16 @@ diff --git a/docs/sitemap.xml b/docs/sitemap.xml index e6cd7ec..8f9fcbc 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -3,6 +3,12 @@ /404.html + + /articles/index.html + + + /articles/understanding-prngs.html + /authors.html diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/understanding-prngs.Rmd b/vignettes/understanding-prngs.Rmd new file mode 100644 index 0000000..27dd140 --- /dev/null +++ b/vignettes/understanding-prngs.Rmd @@ -0,0 +1,53 @@ +--- +title: "Why use randngen" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{understanding-prngs} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r, include = FALSE} +library(randngen) +``` + + +# Introduction + +Pseudo-random number generators power power much of what goes on "behind the scenes" in statistical and cryptographic settings. In `R`, there is a pseudo-random number generator present which allows users to generate random variables from a variety of distributions. To check the default PRNG used by your `R` version you can run the following: + +```{r} +# Using version 4.2.2 (at time of writing) + +RNGkind() +``` + + +The PRNG which R utilizes can be specified by specifying a `.Random.seed` argument in the beginning of the R script or by adjusting the default `kind` (and `normal.kind` and `sample.kind`) arguments in the `RNGkind` or `set.seed` argument. + +While it is possible for one to utilize their own PRNG through use of user-supplied random number generation, such an approach is pedagogically complex and for users interested in working with random number generation and still leaves abstraction around how random numbers are generated from the seed and parameters supplied. + + + + + +# References + +1. Random function - RDocumentation. https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Random. + +2. Morris, T. P., White, I. R. & Crowther, M. J. Using simulation studies to evaluate statistical methods. Statistics in Medicine 38, 2074–2102 (2019). + +3. Generating distributions from random number generators. Cross Validated https://stats.stackexchange.com/questions/637706/generating-distributions-from-random-number-generators. + +4. L’Ecuyer, P. & Simard, R. TestU01. ACM Transactions on Mathematical Software 33, 1–40 (2007).