MyNixOS website logo
Description

Use the MLS Junk Generator Algorithm to Generate a Stream of Pseudo-Random Numbers.

Generate a stream of pseudo-random numbers generated using the MLS Junk Generator algorithm. Functions exist to generate single pseudo-random numbers as well as a vector, data frame, or matrix of pseudo-random numbers.

mlsjunkgen

R-CMD-check CRAN_Status_Badge CoverageStatus RStudio CRAN mirrordownloads

Background

mlsjunkgen is a pseudo-random number generator.

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)

Usage

The package consists of four functions:

  1. junkgen - generates a pseudo-random number from user-specified seeds
  2. mlsjunkgenv - generates a vector of pseudo-random numbers by calling junkgen a user-specified number of times
  3. mlsjunkgend - generates a data frame of pseudo-random numbers by calling junkgen a user-specified number of times
  4. mlsjunkgenm - generates a user-specified size matrix of pseudo-random numbers by calling mlsjunkgenv and assigning the results to a matrix

Examples

junkgen generates a single pseudo-random number based on four user-specified seeds:

w <- 1
x <- 2
y <- 3
z <- 4
junkgen(w = w, x = x, y = y, z = z)
#> [1] 0.9551644

mlsjunkgenv generates a vector containing a stream of n (default = 1) user-specified pseudo-random numbers based on four user-specified seeds rounded to a specified (default = 5) number of decimal places:

mlsjunkgenv(n = 10, w = w, x = x, y = y, z = z, round = 2)
#>  [1] 0.96 0.67 0.21 0.34 0.12 0.56 0.59 0.11 0.34 0.70

The same example with default rounding:

mlsjunkgenv(n = 10, w = w, x = x, y = y, z = z)
#>  [1] 0.95516 0.66908 0.21235 0.34488 0.11995 0.56398 0.59235 0.11432 0.33525
#> [10] 0.70271

mlsjunkgend generates a data frame containing a stream of n user-specified pseudo-random numbers based on four user-specified seeds:

mlsjunkgend(n = 10, w = w, x = x, y = y, z = z, round = 2)
#>      RN
#> 1  0.96
#> 2  0.67
#> 3  0.21
#> 4  0.34
#> 5  0.12
#> 6  0.56
#> 7  0.59
#> 8  0.11
#> 9  0.34
#> 10 0.70

The same example with default rounding:

mlsjunkgend(n = 10, w = w, x = x, y = y, z = z)
#>         RN
#> 1  0.95516
#> 2  0.66908
#> 3  0.21235
#> 4  0.34488
#> 5  0.11995
#> 6  0.56398
#> 7  0.59235
#> 8  0.11432
#> 9  0.33525
#> 10 0.70271

mlsjunkgenm generates a matrix of user-specified size containing a stream of pseudo-random numbers based on four user-specified seeds:

mlsjunkgenm(nrow = 5, ncol = 5, w = w, x = x, y = y, z = z, round = 3)
#>       [,1]  [,2]  [,3]  [,4]  [,5]
#> [1,] 0.955 0.564 0.418 0.052 0.020
#> [2,] 0.669 0.592 0.313 0.663 0.110
#> [3,] 0.212 0.114 0.920 0.802 0.685
#> [4,] 0.345 0.335 0.379 0.160 0.286
#> [5,] 0.120 0.703 0.280 0.586 0.452
Metadata

Version

0.1.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows