middle_square


middle_square, a Fortran90 code which implements the middle square algorithm for generating random integers. 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 GNU LGPL 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 Fortran90 code which implements the Wichman-Hill random number generator (RNG).

collatz_recursive, a Fortran90 code which computes and analyzes the Collatz or hailstone or 3n+1 sequence, using recursive computation;

cycle_brent, a Fortran90 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 Fortran90 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 Fortran90 code which computes elements of a Halton quasirandom sequence.

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

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

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

ranlib, a Fortran90 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 Fortran90 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 Fortran90 code which computes a sequence of uniformly distributed pseudorandom values.

van_der_corput, a Fortran90 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 16 September 2022.