aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2017-12-15 17:26:12 -0500
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2017-12-15 17:26:12 -0500
commitc7c6d55dfb75804b119ae310e5c59ac238348665 (patch)
tree6f7c3882362782eb8a70f039e4d899c11f3becfc /R
parentfix warnings from R about routine registration (diff)
downloadSyncRNG-c7c6d55dfb75804b119ae310e5c59ac238348665.tar.gz
SyncRNG-c7c6d55dfb75804b119ae310e5c59ac238348665.zip
update version and documentation
Diffstat (limited to 'R')
-rw-r--r--R/SyncRNG.R4
-rw-r--r--R/syncrng-package.R50
2 files changed, 53 insertions, 1 deletions
diff --git a/R/SyncRNG.R b/R/SyncRNG.R
index 95e6b3e..e7176b4 100644
--- a/R/SyncRNG.R
+++ b/R/SyncRNG.R
@@ -1,12 +1,14 @@
library(methods)
#' A Reference Class for SyncRNG
+#'
+#' See \link{syncrng-package} for package documentation.
#'
#' @field seed The seed for the random number generator
#' @field state The current state of the RNG, should not be modified by the
#' user
#'
-#' @useDynLib SyncRNG
+#' @useDynLib SyncRNG, .registration = TRUE
#' @export SyncRNG
#' @exportClass SyncRNG
#' @importFrom methods new
diff --git a/R/syncrng-package.R b/R/syncrng-package.R
new file mode 100644
index 0000000..949401d
--- /dev/null
+++ b/R/syncrng-package.R
@@ -0,0 +1,50 @@
+#' @title SyncRNG - Synchronized Random Numbers in R and Python
+#'
+#' @description
+#' The SyncRNG package provides a random number generator implemented in C and
+#' linked to both R and Python. This way, you can generate the same random
+#' number sequence in both languages by using the same seed.
+#'
+#' The package implements a Tausworthe LSFR RNG (more details at
+#' \url{https://gertjanvandenburg.com/blog/syncrng/}). This is a very fast
+#' pseudo-random number generator.
+#'
+#' @section Usage:
+#' There are two ways to use this package in R. It can be used as a reference
+#' class, where a SyncRNG object is used to keep the state of the generator and
+#' numbers are generated using the object methods. It can also be used as a
+#' user-defined random number generator using the strategy outlined in
+#' .Random.user. See the examples section below.
+#'
+#' @author
+#' Gerrit J.J. van den Burg\cr
+#' Maintainer: Gerrit J.J. van den Burg <gertjanvandenburg@gmail.com>
+#'
+#' @references
+#' URL: \url{https://github.com/GjjvdBurg/SyncRNG}
+#'
+#' @examples
+#' library(SyncRNG)
+#'
+#' # As user defined RNG:
+#'
+#' set.seed(0, 'user', 'user')
+#' runif(2)
+#' # [1] 3.666952e-04 6.257184e-05
+#' set.seed(0, 'user', 'user')
+#' rnorm(2)
+#' # [1] 0.01006027 0.42889422
+#'
+#' # As class:
+#'
+#' s <- SyncRNG(seed=0)
+#' s$rand()
+#' # [1] 0.0003666952
+#' s$rand()
+#' # [1] 6.257184e-05
+#'
+#' @name syncrng-package
+#' @docType package
+#' @import methods
+NULL
+#>NULL