{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Z--Daisy-CS100M SP08-FVL-Chap6

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

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

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 - Louis Pasteur 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. 1

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

View Full Document
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 ) satisfy 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 ff ect the resulting estimate of π ?
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 0.76209683302739 0.45646766516834 0.01850364324822 Because the distribution is uniform, the probability that rand is in a given interval [ L, R ] is exactly equal to R L , assuming that the endpoints satisfy 0 L R 1.

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.

{[ snackBarMessage ]}

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