# Random Thoughts

By Cleve Moler, MathWorks

The MATLAB® rand function returns uniformly distributed pseudorandom numbers between 0 and 1. In the past, this function used a multiplicative congruential algorithm pioneered by Berkeley Professor D. H. Lehmer.

In this article, originally published in 1995, Cleve Moler covers random number generation and explains why the rand function in MATLAB 5.0 was updated to use an alternative to the Lehmer algorithm based on work by George Marsaglia. The new algorithm was designed specifically to produce floating-point values–not just scaled integers—and was significantly faster than the one it replaced.

Published 1995 - 92025v00