Skip to content

Commit

Permalink
updated vingette
Browse files Browse the repository at this point in the history
  • Loading branch information
benyamindsmith committed Oct 28, 2024
1 parent fb96b1e commit 1e1dfd3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 23 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ The following is a list of supported random number generators in this package.

- [ ] Knuth-TAOCP-2002 [NOT STARTED]

- [ ] Knuth-TAOCP [NOT STARTED
- [ ] Knuth-TAOCP [NOT STARTED]

- [ ] Rule 30 [NOT STARTED]

## Contributing

Expand Down
46 changes: 34 additions & 12 deletions docs/articles/understanding-prngs.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
understanding-prngs: understanding-prngs.html
last_built: 2024-10-28T03:55Z
last_built: 2024-10-28T23:48Z

33 changes: 25 additions & 8 deletions vignettes/understanding-prngs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,43 @@ 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:
Pseudo-random number generators (PRNGs) 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)
# Returns the methods used for
# 1. The "default" random number generation,
# 2. Normal variable generation
# 3. Discrete uniform variable generation
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.
The PRNG which R utilizes can be specified by specifying a `.Random.seed` argument in the beginning of an 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.
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. For users interested in working with and learning about random number generation, present tools available still leave a degree of complexity and/or mystery around how random numbers are generated from the seed(s) and parameters supplied to a given PRNG. The `randngen` package provides a suite of PRNGs to which aim to be easy to use and flexible for understanding the relevant maths and algorithms implemented by allowing users to specify all relevant parameters.

<!--
Need to write what randngen does
--->

<!--
# From PRNG to Uniform Random Variables (and beyond!)
--->

```{r}
library(randngen)
range01 <- function(x){(x-min(x))/(max(x)-min(x))}
randngen::lcg(seed = 1234, n=10000)|>
range01()|>
hist()
```

```{r}
set.seed(1234)
runif(10000)|>
hist()
```


# References

Expand Down

0 comments on commit 1e1dfd3

Please sign in to comment.