Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simulation Using computers to simulate real- world observations.

Similar presentations


Presentation on theme: "Simulation Using computers to simulate real- world observations."— Presentation transcript:

1 Simulation Using computers to simulate real- world observations

2 Why do we use it? In business, we identify a random variable We want to estimate the probability information of the random variable Problem: Is it not practical to gather reliable data using real-world observations Solution: Replace the real-world observations with computer simulations

3 Types We have two types of simulation that we look at: –Generating integers –Generating values between 0 and 1 with uniform distribution In the next example, we are going to look at creating a simulation by generating integers

4 Example #1 The operator of a phone switchboard at a large company takes a break after every 50 phone calls he handles. To plan for a back-up operator, the office manager would like to have information on the length of time that it might take for a set of 50 calls to arrive at the switchboard. Specifically, she would like to know the probability that, starting at 9am, a run of 50 calls will arrive before 10am

5 Example #1 (continued) It would be impractical for the manager to wait and collect records on thousands and thousands of incoming calls The manager could, instead, collect a small amount of data and then use computer simulation to generate more Using all of this information, the manager could then estimate the probability of a run of 50 calls coming between 9 and 10am

6 Example #1 (continued) For one day, 270 calls were received from 9am to 3pm T is the random variable giving the time, in minutes, between the arrival of successive calls The 270 calls determine 269 time intervals; these intervals are assumed to be independent observations of T Look in Phone Log.xls for the information recorded

7 Example #1 (continued) In Phone Log.xls, the average interval between calls was found to be 1 min, 20 sec Thus, a run of 50 calls would be expected to arrive in 1 hour, 6 min, 40 sec --- i.e., from 9am to 10:06:40 If END is the random variable variable that is the end arrival time for a run of 50 calls, the manager wants P(END < 10:00:00) Why? Estimate the probability by letting Excel simulate 2,000 runs of 50 calls each

8 Creating a Simulation We want to run a simulation that generates 2,000 runs where each run has 50 calls How do you run one run of 50 calls? Need to use 2 database functions: –RANDBETWEEN –VLOOKUP

9 RANDBETWEEN RANDBETWEEN selects a random integer In our case, we wanted it to select a random integer between 1 and 269 –WHY? It is found under the Math & Trig submenu of Function Wizard Syntax: Enter the smallest and largest integer for RANDBETWEEN to return

10 VLOOKUP Once a random number has been picked, VLOOKUP can be used to cross-reference the information we have to find another value VLOOKUP “searches for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify” Let’s look at Phone Log.xls

11 VLOOKUP How do we use VLOOKUP and what do we enter? –Lookup_value – value in the leftmost column of table Since we are generating random numbers, this is where you would use the RANDBETWEEN function –Table_array – Location of table –Col_index_num – Number of the column where value is to be found –Range_lookup – We leave this blank For example, VLOOKUP(RANDBETWEN(1,269),$B$8:$D$276,3) –pick a number between 1 and 269, where the table is from B8:D276 and once you get your random number, find it in the leftmost column of the table and move two cells to the right to find the value you want

12 Generating 2,000 observations Once you have the syntax to generate one run, you can generate how ever many you want Drag the formula to the desired areas (across and down)

13 Finding the Probability Once you have all the observations you want, we can finally answer the original question For the bank manager, she wanted to know what the probability was that a run of 50 calls will arrive between 9 and 10am Use the COUNTIF function to count how many times the values of the last column are less than 10:00:00 Why are we only concerned with the last column of our generated data? Once we have that number, divide it by 2,000 to get the probability

14 New Simulations To get an accurate probability, you should do repeated trials of the simulation –How many repeated trials will be needed to get an accurate probability? How do you know? If you use Phone Log.xls, it is set for manual calculation; thus, you can press F9 to produce a new simulation Repeated trials show that P(END <10:00:00) is about 26%

15 What do you gain with simulation? You only have to gain data for one day as opposed to numerous days For our simulation in Phone Log.xls, we only had to gain one day’s data to get the proability If we didn’t run the simulation, we would have had to gain 7 ½ years worth of data to get about the same approximation This type of method is called bootstrapping

16 Continuous Random Variables For other busines situations, generating integers will not be enough. Thus, using RANDBETWEEN will not be helpful Excel has another function that generates random numbers with a uniform distribution that are between 0 and 1. This function is called RAND.

17 RAND function Syntax: –RAND does not take on any arguments –Type in =RAND( ) in the cell and hit enter Found under Math & Trig submenu of Function Wizard

18 RAND function For example, let’s generate 10 numbers using the function RAND. Thus, P(x  0.5) = ½ because RAND randomly generates the number with a uniform distribution Why? –Each number generated has a probability of 1/n, where n is the amount of numbers that can be generated between 0 and 1. –Now, there are m numbers between 0 and 0.5 and m = ½ (n) because m is half of the numbers between 0 and 1. –Thus, P(x  0.5) = m(1/n) = m/n = (1/2 n)/n = 1/2

19 IF function We would like to have another function that gives us some information about the numbers that have just been generated. This function is called IF and is found under the Logical submenu of the Function Wizard What does the IF function do? –Returns a value if a condition you specify is true –Returns another value if a condition you specifiy is false What condition? –Any value or expression that can be evaluated to be true or false

20 IF function Syntax: –Logical_test – condition specified by you (has to be a condition that can be evaluated by true or false) –Value_if_true – if condition is true, IF returns the value specified (this value needs to be typed in quotes) –Value_if_false – if condition is false, IF returns the value specified (this value needs to be typed in quotes) E.g., IF(B11<=0.5, “H”, “T”) means the following: –if the value in cell B11 is less than or equal to 0.5 return H –if it is greater than 0.5 return T.

21 Example #2 Errors in procedure coding are a major problem for Health Maintenance Organizations (HMO’s). Suppose that Health Associates receives forms from doctors’ offices, with each form requiring two codes. If 5 forms in a random sample from a given office contain more than 1 coding error all together, then a complaint is sent to the doctor. At Doctor Bustamante’s office the actual probabilities of errors on a single form are as follows:

22 Example #2 (continued) Question: What is the probability that a random sample of 5 forms from Dr. Bustamante’s office will contain more than 1 coding error? –I.e, What is P(T > 1), if T is the random variable that observes the number of coding errors in a random sample of 5 forms from Dr. Bustamante’s office?

23 Solution to Example #2 To answer the questions from the previous slide, we will need to look at some probabilities and set up a simulation Let X be the random variable that is the number of coding errors on a single, randomly selected form from Dr. Bustamante’s office. X = 0, 1, or 2 (from the information that was given earlier) We also know that P(X = 0) = 0.90, P(X = 1) = 0.08 and P(X = 2) = 0.02 Thus, E(X) = 0(0.90) + 1(0.08) + 2(0.02) = 0.12

24 Solution to Example #2 (cont.) We are looking for the total number of errors. Thus, we need to look at the random variable T defined earlier. The 5 forms are picked at random and the number of errors on each form are independent observations of X. Since T is the sum of 5 independent observations of X, E(T) = 5*E(X) = 0.60 Use this number as a check when we run our simulation

25 Simulation for Example #2 Look in the file Coding.xls to see 4,000 generated samples [of 5 forms from Dr. Bustamante’s office]. We need to look at how the functions RAND and IF were used. Let’s look at cell G11 in the file – the formula typed there is =IF(B11<=0.90,0,IF(B11<=0.98,1,2)) What does this mean? –Go to B11 – if the number is less than or equal to 0.90 return a 0 (for no errors) – if not, then -- –Go to B11 and if the number is between.090 and.098 (how do we know this is what is meant by the formula) return a 1 (1 error) – if not, then -- –Return a 2 (for 2 errors)

26 Focus on the Project How does all of this relate to our project? We can use the functions RANDBETWEEN and VLOOKUP to create a simulations This simulation will help us determine the price of our option on the starting date of the option

27 Focus on the Project Recall, we have following random variables: –C norm – closing price at the end of the option period (the number of weeks your option ran) –R norm – normalized weekly ratios –FV – normalized value of our option at the end of option period –PV – option price, per share, on starting date of option

28 Focus on the Project If we go to Option Focus.xls we can look in the sheet Simulation to see how RANDBETWEEN and VLOOKUP are used to select random values of R norm After randomly selecting normalized ratios, you can use them to find an observation of the normalized closing price.

29 Focus on the Project How? –take the actual starting price of the stock on the starting date of the option, March 7, 2003 this is found from the historical data –multiply the starting price by a randomly selected normalized ratio – this gives you a current price of your stock for that week –repeat this procedure, using the current week’s stock price (found from the step before) as the number to multiply to the normalized ratio selected do this for the length of your option (how many weeks your option is running) –at the end of your option length, you will have an observation of the normalized closing price, C norm –this is 1 run of your simulation

30 Focus on the Project Once you have an observation of your normalized closing price, we need to use this to find the starting option value. We know that the Future Value of the option (FV) is the max of {S 0 – C norm, 0} (Why?) So for the normalized closing price you found, you should find the corresponding future value of the option –Note – the number will be either 0 or positive Once you have the future value of the option, we can use the present value formula to find the present value of the option (or the value of the option on the starting date of the option).

31 Focus on the Project At the end of this 1 run of the simulation, you will have a value of your option on the starting date of your option You will need to do more than 1 run of your simulation to make your estimate accurate –The more observations you have the better your estimate will be How many runs of your simulation should you have? –The more the better – have at least 5,000 simulations –You can click and drag your formula down 5000 cells and across the number of weeks your option runs to fill in your simulation table

32 Focus on the Project Once you have 5,000 runs, this means that you will have 5,000 observations of your closing price. Thus, you can find 5,000 future values of your option and in turn, find 5,000 values of your option price (PV) Find the sample mean of these 5,000 observations of PV which provides an approximation of E(PV) Each time the simulation is recomputed (by pressing F9), a new E(PV) is calcuated. Run your simulation at least 20 times – this provides you with 20 approximate values of E(PV) Average these numbers together to determine your option price, per share

33 Focus on the Project 5,000 runs to compute one E(PV) and running the simulation 20 times to produce 20 E(PV)’s produced 100,00 simulations Is this enough simulations? How can you tell? Well, what happens if you run 200,000 simulations? 300,000 simulations? Will you be getting a more accurate price? You will need to look in to this issue – –perhaps you can graph the values that you get of E(PV) when you run the simulation 100,000, 200,000, 300,00 times – what is the graph telling you?

34 What should you do? You will need to input your data into the given simulation (or better yet, create your own from hand – you will understand it better if you do this!) If you just change the simulation, what do you need to input? –Change all cell references to match your data –Some examples are (might not be all): The number of weeks of ratios you have Your week dates Your normalized ratios Change the length of time your option is running for (match with your data) – there are many cell references for this Actual closing price of stock on March 7, 2003 Change the cell references in the formulas to match the length of your option time and the number of normalized ratios you have

35 What should you do? After creating your own simulation OR changing the current simulation, you should end up with one value for E(PV) Run the simulation (by hitting F9) at least 20 times Record the values obtained for E(PV) and average them together This number produces a final estimate for the value of your option on March 7, 2003, per share Remember our underlying is 100 shares, so your option premimum will be the value of your option, per share, multiplied by 100.


Download ppt "Simulation Using computers to simulate real- world observations."

Similar presentations


Ads by Google