Computers are often used to generate random numbers, which are useful for the simulation of physical phenomena, testing, statistical analysis, and computer games.
In this chapter, we first define what we mean by “random” and ask whether or not an algorithm can truly generate random numbers. We then examine algorithms for generating uniformly distributed, normally distributed, and exponentially distributed random numbers.
Finally, we look at a Monte Carlo algorithm, which uses random numbers to derive a result. The algorithm we'll examine is Buffon's needle, which gives us yet another way to compute the value of π—not as precise as the algorithms in Chapter 13, but certainly intriguing.