Chapter 14. Generating Random Numbers

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.

Pseudorandom Numbers

Truly ...

Get Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.