O'Reilly logo

Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing by Ronald Mak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required