mlsjunkgen is an R package that generates pseudo-random numbers using the MLS Junk Generator algorithm (see below).

### Background

I took a course in graduate school (“Statistical Analysis for Digital Simulation”) at Texas Tech from Dr. Elliot Montes in which we spent a lot of time on the generation and analysis of random numbers. Here is a simple-yet-powerful pseudo-random number generator that I learned about in that course. It is named “The MLS Junk Generator” after Dr. Milton L. Smith.

I have also released an Excel/VBA implementation and provided the simple R code used as the basis for this package.

#### Algorithm

For any seed values of w, x, y, z:

ri = 5.980217w2 + 9.446377x0.25 + 4.81379y0.33 + 8.91197z0.5

ri = ri - Int(ri)

For ri+1:

w = x

x = y

y = z

z = ri

#### Analysis

This generator tends to do well with various tests for randomness (K-S, Chi Square, test for runs up and down). It may not perform as well on other tests (e.g., tests for runs above and below the mean), but that could relate to my choice of seeds. As a point of reference, the period of Excel’s built-in random number generator is 16,777,216 and the MLS Junk Generator’s period is something greater than 9.9 billion (the point at which I gave up on trying to determine it).

### Installation

• mlsjunkgen is available on CRAN and can be installed accordingly:

install.packages("mlsjunkgen")
library(mlsjunkgen)
• You can also install mlsjunkgen from GitHub using the devtools package:

install.packages("devtools")
library("devtools")
install_github("scumdogsteev/mlsjunkgen")
library(mlsjunkgen)