middle_square


middle_square, a MATLAB code which implements the middle square random number generator (RNG). This is a very early method, attributed to von Neumann, which actually is deeply flawed, with short cycles.

Licensing:

The computer code and data files made available on this web page are distributed under the MIT license

Languages:

middle_square is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

middle_square_test

asa183, a MATLAB code which implements the Wichman-Hill random number generator (RNG).

collatz, a MATLAB code which computes and analyzes the Collatz or hailstone or 3n+1 sequence;

cycle_brent, a MATLAB code which carries out an iterated function evaluation, and seeks to determine the nearest element of a cycle, and the cycle length, using the Brent method.

cycle_floyd, a MATLAB code which carries out an iterated function evaluation, and seeks to determine the nearest element of a cycle, and the cycle length, using the Floyd method.

halton, a MATLAB code which computes elements of a Halton quasirandom sequence.

hammersley, a MATLAB code which computes elements of a Hammersley quasirandom sequence.

matlab_random_test, a MATLAB code which tests the system random number generators.

normal, a MATLAB code which computes a sequence of pseudorandom normally distributed values.

random_sorted, a MATLAB code which generates vectors of random values which are already sorted.

ranlib, a MATLAB code which produces random samples from Probability Density Functions (PDF's), including Beta, Chi-square Exponential, F, Gamma, Multivariate normal, Noncentral chi-square, Noncentral F, Univariate normal, random permutations, Real uniform, Binomial, Negative Binomial, Multinomial, Poisson and Integer uniform, by Barry Brown and James Lovato.

rnglib, a MATLAB code which implements a random number generator (RNG) with splitting facilities, allowing multiple independent streams to be computed, by L'Ecuyer and Cote.

uniform, a MATLAB code which computes a sequence of uniformly distributed pseudorandom values.

van_der_corput, a MATLAB code which computes elements of a van der Corput quasirandom sequence.

Reference:

  1. Brian Hayes,
    The Middle of the Square,
    08 August 2022,
    http://bit-player.org/

Source Code:


Last modified on 18 June 2023.