22-pseudorandom-numbers

22-pseudorandom-numbers - Handout #22 CS 106A July 9, 2009...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 2

22-pseudorandom-numbers - Handout #22 CS 106A July 9, 2009...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online