RandPlot

About this project
Plots the distribution of random numbers.
Wiki / Home

Overview

RandPlot is single window WPF application that plots random numbers generated by a wide variety of pseudo-random number generator (PRNG) algorithms. Author's Note - I've been planning for about 10 years to rewrite the program using WPF, but I never get around to it.

The plotting technique is not based on any solid theory, it simply takes consecutive (x,y) pairs of floating-point numbers generated by the different PRNG algorithms, reduces them to the range 0-1023 and plots a corresponding (x,y) point in a 1024×1024 grid. Despite the simplicity of the process, the plots often reveal flaws in algorithms due to poor distribution or a lattice structure. The plot can be stretched by a factor from 1 to 1,000,000 horizontally and vertically to help reveal patterns.

RandPlot was inspired by a 1988 article by Pierre L'Ecuyer where he shows how to combine Linear Congruential Generators to create simple and effective random number generators with excellent properties and very long periods. In his article he prints 3 plots of random number points stretched by a factor of 1000.

At the bottom right corner of the window a small scrolling graph shows how the random numbers can be used to slowly converge to an approximate value of π using Monte-Carlo sampling.

From 1MB to 1GB of random bytes can be saved using the currently selected algorithm. The file is in a format suitable for feeding into randomness testing routines.

For an historical discussion of random number generators see Orthogonal Programming - Random Numbers .

A large number of PRNG algorithms have been published. See List of Random Number Generators .

Algorithms

  • LCG (you can adjust the variables in the ax+b mod m iteration).
  • "Quick and Dirty" 32-bit and 64-bit MLCG (you can adjust the variables in the ax+b iteration).
  • .NET Random class. As my web page about random numbers mentions, the .NET Random class switched from using the Knuth Subtractive Generator to one of the xoroshiro algorithms in .NET 6 and later. This project targets .NET 4.8, so it will be using Knuth's algorithm.
  • .NET RandomNumberGenerator class.
  • Xoroshiro128++ and 256++
  • SplitMix
  • Mersenne Twister 32-bit and 64-bit.
  • .NET Guid.NewGuid () ToByteArray or GetHashCode method.
  • The rand function in the standard C library (called via Interop).
  • L'Ecuyer 1988 MLCG x 2 (plain).
  • L'Ecuyer 1988 MLCG x 2 (shuffled).
  • L'Ecuyer 1988 CMRG x 3 (aka MRG63k3a).
  • L'Ecuyer 1999 32-bit LFSR x 4 (aka LFSR113).
  • L'Ecuyer 1999 64-bit LFSR x 5 (aka LFSR258).
  • Marsaglia
  • Wichmann-Hill
  • KISS
  • JKISS
  • ISAAC

Screen Shots

RandPlot Window
Click to see the full-sized 1371×1124 screenshot

Zoom of the Pi calculation control
Close-up of the π calculator

Zoom of the save controls
Close-up of the save controls

Orthogonal Programming Link