Simulation Examples in EXCEL

Download Report

Transcript Simulation Examples in EXCEL

Simulation Examples in EXCEL

Montana Going Green 2010

Example 1

• Flip of a fair coin

Algorithm

• Inputs: Number of trials (flips), N • Output: P(H), P(T) • Step 1: Set Counter H and T at 0.

• Step 2: For I = 1 to N (number of flips) do • Step 3: Generate a random number, x i , between [0,1] • Step 4: If 0 < x i < .5, then H=H+1, else T=T+1 • Step 5: Calculate P(H) = H/N and P(T)=T/N • Output P(H) and P(T) • Stop

Go to EXCEL

Example 2

• Area under a nonnegative curve such as

y=x 3

from [0,2].

Algorithm

INPUT The total number of random points, N. The nonnegative function, f(x), the interval for x [a,b] and an interval for y [0,M] where M > max f(x),a

A

M

 (

b

a

) 

counter N

Stop

Let’s go to EXCEL

Example 3 Buffon Needle Experiment

• In mathematics ,

Buffon's needle problem

is a question first posed in the 18th century by Georges-Louis Leclerc, Comte de Buffon : – Suppose we have a floor made of parallel the same width, and we drop a needle strips of wood , each onto the floor. What is the probability that the needle will lie across a line between two strips? • Buffon's needle was the earliest problem in geometric probability to be solved; it can be solved using integral geometry . The solution, in the case where the needle is not greater than the width of the strips, can be used to design a Monte Carlo method number π .

for approximating the

Needle Experiment

Process

Buffon Needle Experiment

Let x be a uniform (0,1) that expresses the location of the end of the needle.

Let y be a uniform (o, pi) that gives the angle of the needle (0 is horizontal) Let t = x+1*sin(y) be the horizontal projection of the needle If t(i) > 1 Needle intersects line Pi= 2 * (length of needle)/distance between parallel line * (number of tosses)/number crossing parallel line If you allow the needle to be equal to the distance between parallel lines then Pi=2 * number of tosses/# crossing lines If you allow the needle to be equal to the distance between parallel

Go to EXCEL

Fun Game Monty Hall

• Here is the typical scenario. Monty has the grand prize behind one of three doors. The contestant picks a different door. Monty choose the a different door (not yours and not the grand prize). Do you stay with your pick or switch to the other door?

• This question became a big discussion with in Parade Magazine.

• The problem was originally posed in a letter by Steve Selvin to the

American Statistician

in 1975. A well-known statement of the problem was published in Marilyn vos Savant 1990: 's "Ask Marilyn" column in

Parade

magazine in • Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

• — Whitaker/vos Savant 1990

• Throughout the many years of CBS drama series

NUMB3RS

Let's Make A Deal

's popularity, mathematicians have been fascinated with the possibilities presented by the "Three Doors" ... and a mathematical urban legend has developed surrounding "The Monty Hall Problem." The featured the Monty Hall Problem in the final episode of its 2004-2005 season. The show's mathematician offered his own, very definite solution to the problem involving hidden cars and goats. • The 2008 movie

21

opens with an M.I.T. math professor (played by Kevin Spacey) using the Monty Hall Problem to explain mathematical theories to his students. His lecture also includes the popular "goats and cars behind three doors" example favored by many versions of the Problem

Let’s go to EXCEL

Other problems

• Service with a smile: A small service department has one server. Customers arrive according to the distribution in Table 1. The server can handle the customers according to the distribution in Table 2. You want to use a simulation to estimate the busy time of the server, the average length of the queue, the average waiting time of customers, and the average number of customers present. Use a simulation with one hundred events.

Tables for Problem

Table 1 Interarrival time (minutes) 1 2 3 4 Table 2 Service time (minutes) 1 2 3 Probability 0.20 0.30 0.35 0.15 Probability 0.35 0.40 0.25