22-pseudorandom-numbers

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

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
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 today’s class appears in section 6.1 of the text, which covers how to use the RandomGenerator class in acm.util . Here’s an extra problem we won’t 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

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online