Escolar Documentos
Profissional Documentos
Cultura Documentos
A Monte Carlo method is a technique that involves using random numbers and probability to solve problems. The term Monte Carlo Method was coined by S. Ulam and Nicholas Metropolis in reference to games of chance, a popular attraction in Monte Carlo, Monaco (Hoffman, 1998; Metropolis and Ulam, 1949). Computer simulation has to do with using computer models to imitate real life or make predictions. When you create a model with a spreadsheet like Excel, you have a certain number of input parameters and a few equations that use those inputs to give you a set of outputs (or response variables). This type of model is usually deterministic, meaning that you get the same results no matter how many times you re-calculate. [ Example 1: A Deterministic Model for Compound Interest ]
Figure 1: A parametric deterministic model maps a set of input variables to a set of output variables.
Monte Carlo simulation is a method for iteratively evaluating a deterministic model using sets of random numbers as inputs. This method is often used when the model is complex, nonlinear, or involves more than just a couple uncertain parameters. A simulation can typically involve over 10,000 evaluations of the model, a task which in the past was only practical using super computers.
Example 2: A Stochastic Model
By using random inputs, you are essentially turning the deterministic model into a stochastic model. Example 2 demonstrates this concept with a very simple problem. [ Example 2: A Stochastic Model for a Hinge Assembly ] In Example 2, we used simple uniform random numbers as the inputs to the model. However, a uniform distribution is not the only way to represent uncertainty. Before describing the steps of the general MC simulation in detail, a little word about uncertainty propagation: The Monte Carlo method is just one of many methods for analyzing uncertainty propagation, where the goal is to determine how random variation, lack of knowledge, or error affects the sensitivity, performance, or reliability of the system that is being modeled. Monte Carlo simulation is categorized as a sampling method because the inputs are randomly generated from probability distributions to simulate
the process of sampling from an actual population. So, we try to choose a distribution for the inputs that most closely matches data we already have, or best represents our current state of knowledge. The data generated from the simulation can be represented as probability distributions (or histograms) or converted to error bars, reliability predictions, tolerance zones, and confidence intervals. (See Figure 2). Uncertainty Propagation
Figure 2: Schematic showing the principal of stochastic uncertainty propagation. (The basic principle behind Monte Carlo simulation.)
If you have made it this far, congratulations! Now for the fun part! The steps in Monte Carlo simulation corresponding to the uncertainty propagation shown in Figure 2 are fairly simple, and can be easily implemented in Excel for simple models. All we need to do is follow the five simple steps listed below:
Step 1: Create a parametric model, y = f(x1, x2, ..., xq). Step 2: Generate a set of random inputs, xi1, xi2, ..., xiq. Step 3: Evaluate the model and store the results as yi. Step 4: Repeat steps 2 and 3 for i = 1 to n.
Step 5: Analyze the results using histograms, summary statistics, confidence intervals, etc.
On to an example problem ...
1.
2.
3.
MCExample_SalesForecast.zip File Size: ~420 kB Requirements: Excel 97 or Later No Macros Used
Download: Click on the download link or image to the left and save the file on your computer. Depending on your browser and operating system, you may need to "right-click" on the link and select "Save Target As..." Unzip: You will need to "unzip" the file using a program such as Winzip. You can download a free evaluation version of WinZip at www.winzip.com. Open in Excel: After extracting the spreadsheet from the .zip file, open it in Excel. If calculation is too slow on your machine, you may need to remove or disable the COUNTIF formulas (used in the cumulative probability calculations).
Both income and expenses are uncertain parameters, but we aren't going to stop here, because one of the purposes of developing a model is to try to break the problem down into more fundamental quantities. Ideally, we want all the inputs to be independent. Does income depend on expenses? If so, our model needs to take this into account somehow. We'll say that Income comes solely from the number of sales (S) multiplied by the profit per sale (P) resulting from an individual purchase of a gadget, so Income = S*P. The profit per sale takes into account the sale price, the initial cost to manufacturer or purchase the product wholesale, and other transaction fees (credit cards, shipping, etc.). For our purposes, we'll say the P may fluctuate between $47 and $53. We could just leave the number of sales as one of the primary variables, but for this example, Company XYZ generates sales through purchasing leads. The number of sales per month is the number of leads per month (L) multiplied by the conversion rate (R) (the percentage of leads that result in sales). So our final equation for Income is: Income = L*R*P We'll consider the Expenses to be a combination of fixed overhead (H) plus the total cost of the leads. For this model, the cost of a single lead (C) varies between $0.20 and $0.80. Based upon some market research, Company XYZ expects the number of leads per month (L) to vary between 1200 and 1800. Our final model for Company XYZ's sales forecast is: Profit = L*R*P - (H + L*C) Y = Profits X1 = L X2 = C X3 = R X4 = P Notice that H is also part of the equation, but we are going to treat it as a constant in this example. The inputs to the Monte Carlo simulation are just the uncertain parameters (Xi). This is not a comprehensive treatment of modeling methods, but I used this example to demonstrate an important concept in uncertainty propagation, namely correlation. After breaking Income and Expenses down into more fundamental and measurable quantities, we found that the number of leads (L) affected both income and expenses. Therefore, income and expenses are not independent. We could probably break the problem down even further, but we won't in this example. We'll assume that L, R, P, H, and C are all independent. Note: In my opinion, it is easier to decompose a model into independent variables (when possible) than to try to mess with correlation between random inputs.
The table above uses "Min" and "Max" to indicate the uncertainty in L, C, R, and P. To generate a random number between "Min" and "Max", we use the following formula in Excel (Replacing "min" and "max" with cell references): = min + RAND()*(max-min) You can also use the Random Number Generation tool in Excel's Analysis ToolPak Add-In to kick out a bunch of static random numbers for a few distributions. However, in this example we are going to make use of Excel's RAND() formula so that every time the worksheet recalculates, a new random number is generated. Let's say we want to run n=5000 evaluations of our model. This is a fairly low number when it comes to Monte Carlo simulation, and you will see why once we begin to analyze the results. A very convenient way to organize the data in Excel is to make a column for each variable as shown in the screen capture below.
Cell A2 contains the formula: =Model!$F$14+RAND()*(Model!$G$14-Model!$F$14) Note that the reference Model!$F$14 refers to the corresponding Min value for the variable L on the Model worksheet, as shown in Figure 1. (Hopefully you have downloaded the example spreadsheet and are following along.) To generate 5000 random numbers for L, you simply copy the formula down 5000 rows. You repeat the process for the other variables (except for H, which is constant).
Until I get around to providing another example that uses macros, let me just say that if your model is not simple enough to include in a single formula you can create your own custom Excel function (see my article on user-defined functions), or you can create a macro to iteratively evaluate your model and dump the data into a worksheet in a similar format to this example. In practice, it is usually more convenient to buy an add-on for Excel than to do a Monte Carlo analysis from scratch every time. But not everyone has the money to spend, and hopefully the skills you will learn from this example will aid in future data analysis and modeling.
Monte Carlo Simulation Monte Carlo simulation is a versatile method for analyzing the behavior of some activity, plan or process that involves uncertainty. If you face uncertain or variable market demand, fluctuating costs, variation in a manufacturing process, or effects of weather on operations, or if you're investing in stocks, developing a new drug, or drilling an oil well -- you can benefit from using Monte Carlo simulation to understand the impact of uncertainty, and develop plans to mitigate or otherwise cope with risk. This page introduces Monte Carlo and explains why you might need it, and what you need to know (or learn) in order to use it. For background on computer-based simulation methods, consult our Simulation Overview. For background on risk analysis and simulation, see our Risk Analysis Overview. To learn more about key concepts in dealing with risk and uncertainty, consult our Risk Analysis Tutorial.
What is Monte Carlo Simulation? Why Should I Use Monte Carlo Simulation? What Knowledge Do I Need to Use It? How Will This Help Me in My Work or Career?
What is Monte Carlo Simulation? The Monte Carlo method was invented by scientists working on the atomic bomb in the 1940s, who named it for the city in Monaco famed for its casinos and games of chance. Its core idea is to use random samples of parameters or inputs to explore the behavior of a complex system or process. The scientists faced physics problems, such as models of neutron diffusion, that were too complex for an analytical solution -- so they had to be evaluated numerically. They had access to one of the earliest computers -- MANIAC -- but their models involved so many dimensions that exhaustive numerical evaluation was prohibitively slow. Monte Carlo simulation proved to be surprisingly effective at finding solutions to these problems. Since that time, Monte Carlo methods have been applied to an incredibly diverse range of problems in science, engineering, and finance -- and business applications in virtually every industry. Why Should I Use Monte Carlo Simulation? Whenever you need to make an estimate, forecast or decision where there is significant uncertainty, you'd be well advised to consider Monte Carlo simulation -- if you don't, your estimates or forecasts could be way off the mark, with adverse consequences for your decisions! Dr. Sam Savage, a noted authority on simulation and other quantitative methods, says "Many people, when faced with an uncertainty ... succumb to the temptation of replacing the uncertain number in
question with a single average value. I call this the flaw of averages, and it is a fallacy as fundamental as the belief that the earth is flat." Most business activities, plans and processes are too complex for an analytical solution -- just like the physics problems of the 1940s. But you can build a spreadsheet model that lets you evaluate your plan numerically -- you can change numbers, ask 'what if' and see the results. This is straightforward if you have just one or two parameters to explore. But many business situations involve uncertainty in many dimensions -- for example, variable market demand, unknown plans of competitors, uncertainty in costs, and many others -just like the physics problems in the 1940s. If your situation sounds like this, you may find that the Monte Carlo method is surprisingly effective for you as well. What Knowledge Do I Need to Use It? To use Monte Carlo simulation, you must be able to build a quantitative model of your business activity, plan or process. One of the easiest and most popular ways to do this is to create a spreadsheet model using Microsoft Excel -- and use Frontline Systems' Risk Solver as a simulation tool. Other ways include writing code in a programming language such as Visual Basic, C++, C# or Java - with Frontline's Solver Platform SDK -- or using a special-purpose simulation modeling language.You'll also need to learn (or review) the basics of probability and statistics. To deal with uncertainties in your model, you'll replace certain fixed numbers -- for example in spreadsheet cells -- with functions that draw random samples from probability distributions. And to analyze the results of a simulation run, you'll use statistics such as the mean, standard deviation, and percentiles, as well as charts and graphs. Fortunately, there are great software tools (like ours!) to help you do this, backed by technical support and assistance.