This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Handout #22 CS 106A July 9, 2009 Pseudorandom Numbers The material for the last half of todays class appears in section 6.1 of the text, which covers how to use the RandomGenerator class in acm.util . Heres an extra problem we wont get to in class, which appears as exercise 3 on page 214. 3. Although it is often easiest to think of random numbers in the context of games of chance, they have other, more practical uses in computer science and mathematics. For example, you can use random numbers to generate a rough approximation of the constant by writing a simple program that simulates a dart board. Imagine that you have a dart board hanging on your wall. It consists of a circle painted on a square backdrop, as in the following diagram: If you throw darts at this board in a random fashion, some will fall inside the circle, but some will fall outside. If the tosses are truly random, the ratio of the number of darts that land inside the circle to the total number of darts hitting the square should be roughly equal to the...
View Full
Document
 Fall '08
 SAHAMI,M

Click to edit the document details