Z--Daisy-CS100M SP08-FVL-Chap6

Z--Daisy-CS100M SP08-FVL-Chap6 - Chapter 6 Randomness 6.1...

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

View Full Document Right Arrow Icon
Chapter 6 Randomness 6.1 Safety in Numbers Monte Carlo Simulation 6.2 Four Neighbors Random Walks 6.3 Order From Chaos Polygon Averaging Using the computer to simulate random processes sounds like an impossible task. Computer programs execute with total predictability, which is about as far as you can get from dice rolling, brownian motion, and chance mutation. But these are deep waters: God does not play dice with the universe” - Albert Einstein All nature is but art unknown to thee; All chance, direction which thou canst not see; - Alexander Pope Chance favors the prepared mind -Lou isPasteur The message here is that perhaps there are more connections between the random and nonrandom than meet the (human) eye. This is precisiely the case when we use Matlab ’s pseudo-random number generators rand and randn . These functions are capable of generating seemingly random sequences of real numbers. We shall not be concerned with an assessment of their quality; statistically speaking they turn out to be great. Instead, we focus on how they can be used to simulate random events. In § 6.1 we show how to estimate π by simulating a random dart-throwing “game” whose expected score relates to the area of a circle. The classic example of random walks is considered in § 6.2 where we estimate various “exit times” through repeated, simulated coin tosses. In § 6.3 we present a simulation that starts with a random polygon that is a jumble of crossing edges and proceeds to “round it out” through a repeated averaging process.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Chapter 6. Randomness 6.1 Safety In Numbers Problem Statement Consider a target that consists of a 2-by-2 yellow square centered at the origin with a white unit disk “bullseye”. See Figure 6.1. A dart is thrown at the target (1,1) (1,-1) (-1,1) (-1,-1) Figure 6.1. A Target and lands randomly inside the square. We say that the dart is a “hit” if it lands inside the bullseye. This just means that the landing coordinates ( x, y )sat is fy x 2 + y 2 1 . If we throw n darts and n is a large number, then the fraction of darts that hit the bullseye should approximate the ratio of the bullseye’s area to the square’s area, i.e., hits n π 4 This provides a vehicle for estimating π : π 4 hits n . Write a script that simulates the throwing of 10,000 darts and displays the result- ing π -estimate. The darts should be evenly distributed across the square. What happens if the darts are “aimed” at the origin? How does this a f ect the resulting estimate of
Background image of page 2
6.1. Safety In Numbers 3 Program Development The rand function can be used to simulate random events such as the throwing of a dart. If n is an initialized integer, then the script for k=1:n r=rand end displays a sequence of numbers with the property that (a) each number is in between zero and one and (b) scrutiny of the sequence reveals no discernable pattern, e.g., 0.95012928514718 0.23113851357429 0.60684258354179 0.48598246870930 0.89129896614890
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/30/2008 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell University (Engineering School).

Page1 / 23

Z--Daisy-CS100M SP08-FVL-Chap6 - Chapter 6 Randomness 6.1...

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

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