Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/13/2015 1 DECISION MODELING WITH MICROSOFT EXCEL Chapter 9 Copyright 2001 Prentice Hall Monte Carlo Simulation Part 1.

Similar presentations


Presentation on theme: "10/13/2015 1 DECISION MODELING WITH MICROSOFT EXCEL Chapter 9 Copyright 2001 Prentice Hall Monte Carlo Simulation Part 1."— Presentation transcript:

1 10/13/2015 1 DECISION MODELING WITH MICROSOFT EXCEL Chapter 9 Copyright 2001 Prentice Hall Monte Carlo Simulation Part 1

2 10/13/2015 2 Simulation allows you to quickly and inexpensively acquire knowledge concerning a problem that is usually gained through experience (which is often costly and time consuming). Introduction An experimental device (simulator) will “act like” (simulate) the system of interest in a quick, cost- effective manner. Goal:To create an environment in which information about alternative actions can be obtained through experimentation. Goal: To create an environment in which information about alternative actions can be obtained through experimentation.

3 10/13/2015 3 SIMULATION vs. OPTIMIZATION In an optimization model, the values of the decision variables are outputs. In a simulation model, the values of the decision variables are inputs. The model evaluates the objective function for a particular set of values. The result of the model is a set of values for the decision variables that will maximize (or minimize) the value of the objective function. The result of the model is a measure of the quality of a suggested solution and the variability in various performance measures due to randomness in the inputs.

4 10/13/2015 4 Simulation and Random Variables Simulation models are often used to analyze a decision under risk. Under risk, the behavior of one or more factors is not known with certainty. For example: demand for a product during the next month the return on an investment the number of trucks that will arrive to be unloaded The factor that is not known with certainty is called the random variable. The behavior of the random variable can be described by a probability distribution. MONTE CARLO METHOD:

5 10/13/2015 5 When should simulation be used? Simulation is one of the most frequently used tools of quantitative analysis today because: 1.Analytical models may be difficult or impossible to obtain, depending on complicating factors. 1. Analytical models may be difficult or impossible to obtain, depending on complicating factors. 2.Analytical models typically predict only average or “steady-state” (long-run) behavior. 2. Analytical models typically predict only average or “steady-state” (long-run) behavior. 3.Simulation can be performed with a variety of software on a PC or workstation. The level of computing and mathematical skill required to design and run a simulator has been substantially reduced. 3. Simulation can be performed with a variety of software on a PC or workstation. The level of computing and mathematical skill required to design and run a simulator has been substantially reduced.

6 10/13/2015 6 Types of Simulation Models Continuous –Based on mathematical equations. –Used for simulating continuous values for all points in time. –Example: The amount of time a person spends in a queue. Discrete –Used for simulating specific values or specific points. –Example: Number of people in a queue.

7 10/13/2015 7 Simulation Methodology: Obtain probabilities from historical data, knowledge of underlying probability distribution, or expert opinion of (subjective) probabilities; Assign random number ranges to probabilities. Obtain random numbers from software packages, printed random number tables (or from your instructor); Use random numbers to “simulate” events.

8 10/13/2015 8 Advantages of Simulation Often leads to a better understanding of the real system. Years of experience in the real system can be compressed into seconds or minutes. Simulation does not disrupt ongoing activities of the real system. Simulation is far more general than mathematical models. Simulation can be used as a game for training experience. Simulation provides a more realistic replication of a system than mathematical analysis. Simulation can be used to analyze transient conditions, whereas mathematical techniques usually cannot. Many standard packaged models, covering a wide range of topics, are available commercially. Simulation answers what-if questions.

9 10/13/2015 9 Disadvantages of Simulation There is no guarantee that the model will, in fact, provide good answers. There is no way to prove reliability. Building a simulation model can take a great deal of time. Simulation may be less accurate than mathematical analysis because it is randomly based. A significant amount of computer time may be needed to run complex models. The technique of simulation still lacks a standardized approach.

10 10/13/2015 10 Simulation Applications Machine Breakdown problems Queuing problems Inventory problems Portfolio allocations Training Many other applications

11 10/13/2015 11 To generate a random variable, draw a random sample from a given probability distribution. Generating Random Variables Two broad categories of random variables: Can assume only certain specific values (e.g., integers) Can take on any fractional value (an infinite number of values) Continuous Discrete

12 10/13/2015 12 The game spinner below is an example of a physical device used to generate demand in a given model. Once spun, the spinner is equally likely to point to any point on the circumference of the circle. If the areas of the sectors are made to correspond to the probabilities of different demands, the spinner can be used to simulate demand. Each spin represents a trial. 12 (10.0%) 13 (10.0%) 8 (10.0%) 11 (20.0%) 10 (30.0%) 9 (20.0%)

13 10/13/2015 13 Although easy to understand, the spinner method of generating random numbers would be difficult to use if thousands of trials are necessary. Therefore, random number generators have been developed in spreadsheets. Using a Random Number Generator in a Spreadsheet To generate demand for a given model, first assign a range of random numbers to each possible demand. To do this correctly, the proportion of total numbers assigned to a demand must equal the probability of that demand.

14 10/13/2015 14 For example, using the interval from 0 to 1, make the following assignment: 10% of the interval is assigned to 13 30% of the interval is assigned to 10 20% of the interval is assigned to 11 The probability of drawing a number in the range of.90 to.99999 is 1 out of 10 or 0.1 (10%). This method is useful for generating discrete random variables.

15 10/13/2015 15 To generate a discrete random variable with the RAND() function in a spreadsheet, two things are needed: A GENERALIZED METHOD: 1. The ability to generate discrete uniform random variables 2. The distribution of the discrete random variable to be generated To generate a continuous random variable, two things are needed: 1. The ability to generate continuous uniform random variables on the interval 0 to 1 2. The distribution (in the form of the cumulative distribution function) of the random variable to be generated

16 10/13/2015 16 Continuous Uniform Random Variables. It is important to distinguish between U (the uniform random variable on the interval 0 to 1) and u (a specific realization of that random variable)..25.5.75 0 The game spinner can be used to generate values of U. Every point on the circumference of the circle corresponds to a number between 0 and 1. However, it is impractical for a continuous distribution since the exact point must be read (e.g.,.4999999999).

17 10/13/2015 17 The Cumulative Distribution Function (CDF). Consider a random variable, D, the demand. The CDF for D [called F(x)] is then defined as the probability that D takes on a value < x. F(x) = Prob{D < x} Knowing the probability distribution for D, the CDF for key values of D is: With a continuous distribution, the probability that any specific value occurs is 0. Therefore, continuous random variables do not have probability distributions. They are defined by the density function and the CDF. X 8 9 10 11 12 13 X 8 9 10 11 12 13 F(x) 0.1 0.3 0.6 0.8 0.9 1.0

18 10/13/2015 18 Probability x F(x) Here is a graph of the CDF. To generate a discrete demand using the graph: Step 2: Read the particular value of the random quantity, d, on this axis Step 1: Locate the particular value of U on this axis u d

19 10/13/2015 19 THE GENERAL METHOD APPLIED TO CONTINUOUS DISTRIBUTIONS: The two-step process for generating a continuous random variable W is shown below: x Probability F(x)=Prob{W<x} The cumulative distribution function of W u As before, first locate the value (u) of the random variable U w F(w) Then, read the particular value of the random quantity, W, on this axis

20 10/13/2015 20 Data Collection and Random Number Interval Example Suppose you timed 20 athletes running the 100-yard dash and tallied the information into the four time intervals below. Seconds 0-5.99 6-6.99 7-7.99 8 or more TalliesFrequency 4 10 4 2 You then count the tallies and make a frequency distribution. % 20 50 20 10 Then convert the frequencies into percentages. Finally, use the percentages to develop the random number intervals. RN Intervals 01-20 21-70 71-90 91-100

21 10/13/2015 21 Converting Known Probabilities to Cumulative Distribution Frequencies for Discrete Events 1) Determine the number of discrete events and assign each event a probability. 2) Ensure that the sum of all probabilities add to 1. No individual probability is zero or negative. 3) Review all probabilities to determine the level of precision needed. For example, if three possible outcomes has probabilities of 30%, 20%, and 50% the required precision is two decimals. 4) Create a random number table. 5) Pick a random number, per the table. Find which row it falls in. The associated event is considered to have occurred.

22 10/13/2015 22 Converting Known Probabilities to Cumulative Distribution Frequencies for Discrete Events - PRACTICE

23 10/13/2015 23 Machine Breakdown Example Suppose that a given production machine has a 4% chance of breakdown the day after it is serviced. Each day it runs without service the chance of breakdown increases by 3%. The P(Breakdown) can be described as = 0.01 + 0.03x where x = the number of days since service. 1) Calculate X, P(F) and Breaks 2) What are the total number of breakdowns? 3) What was the most days without a breakdown? 4) What was the average number of days without a breakdown? 5) Did this machine ever breakdown two days in a row? Assume service was performed at day zero.

24 10/13/2015 24 Queuing Example Suppose a bank has two loan officers. On average each officer can process 12 clients per hour. On average 24 clients arrive each hour. The true distributions of arrivals and hourly processing abilities are: 1) Assuming the beginning queue is 0, develop a model to simulate a 10 hour day. 2) What is the average number of people in the system? 3) What is the average number of people in queue at the end of each hour? 4) What is the average number of people served each hour? 5) What was the maximum ending queue? 6) What was the most loans processed in a single hour? 7) How many hours had zero people in the ending queue ?

25 10/13/2015 25 Queuing Example

26 10/13/2015 26 Important Distributions Uniform - All possible values are equally likely. Typically uses the =RAND() function in excel to return a continuos number evenly distributed between 0 and 1. Normal - Values are distributed around a mean with a given standard deviation. This is the classic bell curve. In Excel the formula is =NORMINV(RAND(),mean, StDev) Exponential - Typical of arrivals in queuing theory where there is a mean arrival rate. The Excel formula is = -mean * LN (1-rand()) Poisson - Also used for arrival rates in queuing theory. Though possible to formulate in Excel this is generally used in add-in packages such as @Risk or Crystal Ball. Triangular - Use a triangular distribution when the most likely outcome, the minimum outcome, and the maximum outcome are the only things known about the distribution. This can be implemented with Crystal Ball Discrete - Used when something either occurs or does not. For example 2.5 people can not arrive. Either 2 or 3 people show up. These distributions can be uniform, normal, exponential or custom. Custom - This is a user supplied distribution.

27 10/13/2015 27 Generating from the Normal Distribution. The normal distribution plays an important role in many simulation and analytic models. Normality is often assumed. Consider drawing a random demand from a normal distribution with a mean (  ) of 1000 and a standard deviation (  ) of 100. If Z is a unit normal random variable (normally distributed with a mean of 0 and a standard deviation of 1) then  + Z  is a normal random variable with mean  and standard deviation . So, we can draw from a unit normal distribution. Excel has a built-in function that can do this: = NORMINV( RAND(), 1000, 100) Excel will automatically return a normally distributed random number with mean 1000 and std. dev. 100. Generating the Normal Distribution

28 10/13/2015 28 Generating from the Exponential Distribution. The exponential distribution is often used to model the time between arrivals in a queuing model. Its CDF is given by: F(x) = Prob{W < w} = 1 – e - w Where 1/ is the mean of the random variable W. Therefore, we want to solve the following equation for w: u = 1 – e - w The solution is: w = -1/ ln(1- u) Generating the Exponential Distribution

29 10/13/2015 29 Now, to draw a sample from an exponential distribution with a mean of 20 (1/ ) using this equation: 1. First generate a continuous, uniform random number with RAND() (for example,.75). 2.Apply the formula: w = -1/ ln(1- u) = -20 (ln(1-.75)) = -20 (-1.386) = 27.72 In a spreadsheet cell, simply enter: = -20 *LN(1 – RAND() )

30 10/13/2015 30 Suppose you want to model a discrete uniform distribution of demand where the values of 8 through 12 all have the same probability of occurring (uniform, equally likely). The spreadsheet has a function, =RAND(), that returns a random number between 0 and 1. However, this will result in a continuous uniform distribution. To create a discrete uniform distribution, use the INT() function. For example: In general, if you want a discrete, uniform distribution of integer values between x and y, use the formula: INT(x + (y – x + 1)*RAND() ) Discrete Distributions

31 10/13/2015 31 Simulations can be performed with spreadsheets alone. However, add-in software packages can enhance the capabilities of Excel. Simulating with a Spreadsheet Two Excel add-in packages that will be used are Crystal Ball and @Risk. These add-ins offer additional random distributions and easy commands to set up and run many more iterations than could be run in Excel. In addition, they automatically gather statistical and graphical summaries of the results.

32 10/13/2015 32 DISCRETE EVENT SIMULATION INTRODUCTION Typically, simulation refers to a specific class of dynamic models involving the detailed observation of a complex probabilistic system over time. Continuous simulation models involve aggregate variables that change more or less continuously with time (such as those models in Chapter 9). Discrete event simulation is applied whenever individual items are tracked and in which abrupt or nonsmooth changes in the timing of events is the norm.

33 10/13/2015 33 Discrete event simulation models can be used to delve into the fine details of complex systems with many interactions. However, discrete event simulation models can become extremely complex to build and analyze. Discrete event simulation models are most commonly used to create detailed operational systems representing demands among activities requiring scarce resources over time.

34 10/13/2015 34 A single server queuing situation will be used to illustrate a discrete event simulation. EXAMPLE 1 A SIMULATION MODEL IN EXCEL We will illustrate the building of such models using a non-spreadsheet simulation package called Extend. Extend can be used for both continuous simulation and discrete event simulation. We will investigate the relative efficiency of an airport car rental business (Hervis) by modeling the movement of customers through the rental office.

35 10/13/2015 35 Customers arrive in an airport van and queue up, first come – first serve, for service at the rental counter. Eventually, a given customer moves to the head of the queue and, when the rental clerk is free, will receive service that consists of Finally, customers depart, collect their rental car and drive away. filling out the rental forms choosing the rental options receiving some driving instructions etc.

36 10/13/2015 36 Consider the following data giving the relative frequency distribution of customer arrivals in any given 5-minute block of time throughout a typical 24-hour day. Let’s simulate a week of 24-hour operations and segment time into 5-minute blocks. We assume that it will always take exactly 5 minutes to serve a waiting customer.

37 10/13/2015 37 Because 7*24*60/5 = 2016 time blocks (exceeding the 256-column limitation in Excel), the time blocks will be modeled in rows. To build the Hervis model in Excel, first label the time blocks by using the Fill Series option from the Edit menu.

38 10/13/2015 38 Next, create a probability distribution table: Cell K8 computes the expected number of customer arrivals.

39 10/13/2015 39 The computer will be driven by randomly drawn probabilities, which in turn will determine the number of customers arriving in any 5-minute time block. The RAND() function will draw a random fraction greater than or equal to 0 and less than 1, one for each of the 2016 time blocks. Set the Tools – Options – Calculation option to Manual to avoid drawing new random numbers each time the worksheet is changed.

40 10/13/2015 40 Place the =RAND() formula in cell B5 and copy it down to cell B2020 to create all 2016 random fractions. Next, create a modified probability table based on the =RAND() formulas (the inputs). =K4 =M5 + K5 =M6 + K6 =VLOOKUP(B5,$M$4:$N$7,2) The number of customer arrivals, as outputs, are computed by =VLOOKUP() formulas.

41 10/13/2015 41 Column D formulas compute the number of customers in line and being served. =C5 + F4 =MIN(D5,$C$2) =D5 + E5 =MAX(D$5:D$2020) =SUM(D$5:D$2020) =AVERAGE(D$5:D$2020) Column E formulas compute the number of customers receiving rental counter service as being the minimum of the number in line and the number of rental counter stations in C2. Column F computes the number of customers remaining unserved at the end of the 5- minute block.

42 10/13/2015 42 The initial results show that on the average, ½ customer arrives in each 5-min. block (or 1 customer every 10 minutes). It always takes only one 5-min. interval to serve a customer, thus, the rental counter is busy only ½ the time on average. However, during peak times, you could have 9 customers awaiting service, leading to a delay of 45 minutes for the 9 th customer. To alleviate this wait, we could add another rental station. We can use this model to evaluate the effect of adding another rental station, thus allowing up to two waiting customers to receiver service simultaneously.

43 10/13/2015 43 Below is the revised model for 2 rental stations. The revised statistics indicate that the maximum number of customers delayed falls from an average of.499 to an average of.025.

44 10/13/2015 44 A CAPITAL BUDGETING EXAMPLE: ADDING A NEW PRODUCT LINE Airbus Industry is considering adding a new jet airplane (model A3XX) to its product line. The following financial information is available: Startup Costs$150,000 Sales Price$ 35,000 Fixed Costs (per year)$ 15,000 Variable Costs (per year)75% of revenues Tax depreciation on the new equipment would be $10,000 per year over the 4 year expected product life. Salvage value of the equipment at the end of the 4 years is estimated to be 0. Airbus’ cost of capital is 10% and tax rate is 34%.

45 10/13/2015 45 If demand is known, then a spreadsheet can be used to calculate the net present value (NPV). For example, assume that the demand for A3XXs is 10 units for each of the next 4 years: =C9*$B$3=$B$4=C10*$D$2=$B$5=C10-SUM(C11:C13)=$D$4*C14=C14 – C15=C16 + C13 =-$B$2 =NPV($D$3,C17:F17)+B17

46 10/13/2015 46 It is unlikely that demand will be the same every year. A more realistic model would be one in which demand each year is a sequence of random variables. THE MODEL WITH RANDOM DEMAND This model of demand is appropriate when there is a constant base level of demand that is subject to random fluctuations from year to year. Sampling Demand with a Spreadsheet: Assume initially that the demand in a year will be either 8, 9, 10, 11, or 12 units with each value being equally likely to occur. This is an example of a discrete uniform distribution. Now, use the formula =INT(8 + 5*RAND() ) to sample from a discrete uniform distribution on the integers 8, 9, 10, 11, 12. Multiple trials can be performed by pressing the recalculation key for the spreadsheet (e.g., F9).

47 10/13/2015 47 =INT(8+5*RAND() ) Using this formula results in random demands. Hitting the F9 key would result in a different sample of demands, and possibly a different NPV. The demands are random variables, therefore, the NPV is also a random variable.

48 10/13/2015 48 Two questions need to be answered about the NPV distribution: EVALUATING THE PROPOSAL 1. What is the mean or expected value of the NPV? 2. What is the probability that the NPV assumes a negative value (making the proposal to add the A3XX less attractive)? To answer these questions, a simulation model must be built. To run the simulation automatically and capture the resulting NPV in a separate spreadsheet, use the Data Table command.

49 10/13/2015 49 Start with a blank worksheet by clicking on the Insert menu and select Worksheet Next, rename this blank worksheet 100 Iterations

50 10/13/2015 50 Type the starting value (1) in cell A2 and hit Enter, then return to cell A2. Click the Edit menu and choose Fill – Series. In the resulting dialog, select Series in Columns and enter a stop value of 100. Click OK to fill series.

51 10/13/2015 51 Add column titles and the following formula to cell B2. Now select the range A2:B101 and click Data – Table.

52 10/13/2015 52 In the resulting dialog, enter C1 for the column input cell and click OK. Note that since a random number generator is used in the formula, you may get different values than these. Excel will recalculate the values and store the resulting NPV in the adjacent cells in column B.

53 10/13/2015 53 Now, to turn the formulas into actual values upon which we can focus, first select the range of cells B2:B101, then click on the Edit – Copy menu. Next, click on the Edit – Paste Special menu option and in the resulting dialog, choose Values.

54 10/13/2015 54 To get a summary of the 100 iterations, use Excel’s built-in data analysis tool. Click on Tools – Data Analysis. If you do not have this option, click on the Add-in option on the Tools menu and in the resulting dialog, click on Analysis ToolPak. After clicking OK, the Data Analysis dialog will open. Select the Descriptive Statistics option and click OK.

55 10/13/2015 55 In the resulting dialog, choose the Input Range to include the 100 iterations. Now click on Output Range and enter the cell where the output will be placed. In addition, select Summary Statistics and click OK.

56 10/13/2015 56 The resulting analysis gives the estimated mean NPV and standard deviation. Downside Risk and Upside Risk: To get a better idea about the range of possible NPVs that could occur, look at the minimum and maximum NPVs.

57 10/13/2015 57 Distribution of Outcomes: Now we ask the question: How likely will these extreme outcomes occur? To answer this, examine the shape of the distribution of the NPV by creating a histogram. Click on Tools – Data Analysis and choose Histogram. In the resulting dialog, set the input range and choose to save the results in a worksheet called NPV Distribution.

58 10/13/2015 58 In the resulting analysis, the Frequency (column B) indicates the number of trials that fell into the bins (categories) defined by column A. The cumulative % column indicates the cumulative percentage of observations that fall into each category or bin.

59 10/13/2015 59 The histogram gives a visual representation of the distribution of NPVs. Note that it is somewhat bell shaped.

60 10/13/2015 60 The next questions to ask are: How Reliable is the Simulation? 1. What is the mean or expected value of the NPV? 2. What is the probability that the NPV assumes a negative value (making the proposal to add the A3XX less attractive)? In this trial, the mean is $12,100. In this trial, the probability is >15%. 1. How much confidence do we have in the answers from the first trial? 2. Would we be more confident if we ran more trials?

61 10/13/2015 61 For a 95% confidence interval of the Mean, the formula is: estimated mean + 1.96(standard deviation) In this case, the standard deviation is the standard error (the standard deviation divided by the square root of the number of trials). Based on this trial, the upper and lower confidence limits are: =$E$4-1.96*$E$8/SQRT($E$16) =$E$4+1.96*$E$8/SQRT($E$16) So, we have 95% confidence that the true mean NPV is somewhere between $9,679 and $14,521.

62 10/13/2015 62 In summary, 1. Increasing the number of trials is apt to give a better estimate of the expected return. However, there can still be a difference between the simulated average and the true expected return. 2. Simulations can provide useful information on the distribution results. 3. Simulation results are sensitive to assumptions affecting the input parameters.

63 10/13/2015 63 Key Learning's Monte Carlo method Random variables Distributions Cumulative distribution functions Machine breakdown models Queuing models


Download ppt "10/13/2015 1 DECISION MODELING WITH MICROSOFT EXCEL Chapter 9 Copyright 2001 Prentice Hall Monte Carlo Simulation Part 1."

Similar presentations


Ads by Google