Download presentation
Presentation is loading. Please wait.
Published byLukas Curt Hertz Modified over 5 years ago
1
Introduction to Simulation Using Crystal Ball
Chapter 12 Introduction to Simulation Using Crystal Ball
2
Introduction to Simulation
In many spreadsheets, the value for one or more cells representing independent variables is unknown or uncertain. As a result, there is uncertainty about the value the dependent variable will assume: Y = f(X1, X2, …, Xk) Simulation can be used to analyze these types of models.
3
What is a Dependent & an Independent Variable?
Consider the following variables: Grass Growth Frequency of fertilization Amount of sunshine How are these variables related?
4
Dependent Versus Independent Variables
Grass growth is a function of frequency of fertilization and amount of sunshine. Or mathematically: Grass growth = f(frequency of fertilization, amount of sunshine) Thus, grass growth is labeled as the dependent variable, while fertilization and sunshine would be the independent variables.
5
Another Example Suppose that you are self-employed. In a given month, your profit (bottom line performance measure) will obviously be a function of your monthly revenues and costs (i.e., revenues & costs are your independent variables).
6
Example (continued) What is the mathematical function linking profit to revenues and costs? Simple! Profit = Total Revenue – Total Cost Thus, if you know with certainty the values of revenue and cost, then we will know with certainty the value of the dependent variable profit.
7
Example (continued) However, in real life applications we may not know what our future revenues or costs will be. That is they are called random variables. This is were simulation comes to the rescue. For instance, assume that based on historical data our monthly revenues range between $1000 and $2000 (assume that any value in this range occurs with an equal likelihood).
8
Example (continued) Also, assume that our monthly costs resemble a bell-shaped curve (i.e., a normal distribution) with a mean of $600 and a standard deviation of $150. Note that I have defined the probability distributions for both independent variables? Can you name them?
9
Example (continued) Monthly revenue is actually a continuous uniform distribution (it is called uniform because all values occur with equal likelihood), while cost is a normal probability distribution. Now to simulate a single monthly profit value, we will generate a single revenue value and a single cost value from their corresponding distributions and plug these values into the profit equation identified earlier on.
10
Example (continued) Now we have a single simulated value for one month. Are we going to base our profit estimates based on only a single value? Obviously not! We need to generate hundreds or perhaps thousands of profitability values to get a better feel of our expected monthly profits. This is were a software program such as Crystal Ball can make our job easy!
11
Random Variables & Risk
A random variable is any variable whose value cannot be predicted or set with certainty. Many “input cells” in spreadsheet models are actually random variables. the future cost of raw materials future interest rates future number of employees in a firm expected product demand Decisions made on the basis of uncertain information often involve risk. “Risk” implies the potential for loss.
12
Methods of Risk Analysis
Best-Case/Worst-Case Analysis What-if Analysis Simulation
13
Best-Case/Worst-Case Analysis
Best case - plug in the most optimistic values for each of the uncertain cells. Worst case - plug in the most pessimistic values for each of the uncertain cells. This is easy to do but tells us nothing about the distribution of possible outcomes within the best and worst-case limits.
14
Possible Performance Measure Distributions Within a Range
worst case best case worst case best case worst case best case worst case best case
15
What-If Analysis Plug in different values for the uncertain cells and see what happens. This is easy to do with spreadsheets. Problems: Values may be chosen in a biased way. Hundreds or thousands of scenarios may be required to generate a representative distribution. Does not supply the tangible evidence (facts and figures) needed to justify decisions to management.
16
Simulation Resembles automated what-if analysis.
Values for uncertain cells are selected in an unbiased manner. The computer generates hundreds (or thousands) of scenarios. We analyze the results of these scenarios to better understand the behavior of the performance measure. This allows us to make decisions using solid empirical evidence.
17
Simulation To properly assess the risk inherent in the model we need to use simulation. Simulation is a 4 step process: 1) Identify the uncertain cells in the model. 2) Implement appropriate random numbers for each uncertain cell. 3) Replicate the model n times, and record the value of the bottom-line performance measure. 4) Analyze the sample values collected on the performance measure.
18
What is Crystal Ball? Crystal Ball is a spreadsheet add-in that simplifies spreadsheet simulation. A limited life trial version of Crystal Ball is on the CD-ROM accompanying this book. It provides: dialogs & functions for generating random numbers commands for running simulations graphical & statistical summaries of simulation data
19
Random Number Generators (RNGs)
A RNG is a mathematical function that randomly generates (returns) a value from a particular probability distribution. We can implement RNGs for uncertain cells to allow us to sample from the distribution of values expected for different cells.
20
How RNGs Work =IF(RAND( )<0.5,1,2)
The RAND( ) function in Excel returns uniformly distributed random numbers between 0.0 and Suppose we want to simulate the act of tossing a fair coin. Let 1 represent “heads” and 2 represent “tails” (Note that I could have used other values than “1” and “2” such as “1” and “0”). Consider the following RNG: =IF(RAND( )<0.5,1,2)
21
A function to Simulate Tossing a Single Coin
How to interpret the function: =IF(RAND( )<0.5,1,2) Using =RAND() in Excel will generate a value between 0 and 1 (or to be specific). If the generated value is less than 0.5, then a value of 1 will be returned, and if false a value of 2 will be returned.
22
Excel’s IF Function In general, the “IF Function” in Excel typically has the following format: =IF(condition is true, then return this value, if false then return this value).
23
Note that the previous =RAND() function will simulate the toss of a single coin once. That is, we have replicated the model one time only. To simulate the outcome say 100 times, you simply copy this function in Excel 100 times.
24
Simulating the Roll of a Die
We want the values 1, 2, 3, 4, 5 & 6 to occur randomly with equal probability of occurrence. Consider the following RNG function in Excel =INT(6*RAND())+1 If 6*RAND( ) falls INT(6*RAND( ))+1 in the interval: returns the value: 0.0 to 1.0 to 2.0 to 3.0 to 4.0 to 5.0 to
25
Simulating the Roll of a Die
Try inputting the =INT(6*RAND())+1 function in Excel. You should get a value between 1 and 6. You have just simulated the event of tossing a die once. To simulate this event multiple times, copy this function say 20 times.
26
Simulation with Crystal Ball
Although Excel is quite capable of modeling and running simulation problems, it is much easier to rely on a software that will automate many of our modeling tasks. Crystal Ball, as stated earlier, is an add-in macro that attaches itself to Excel thus giving you the look and feel of Excel itself.
27
Generating Random Numbers With Crystal Ball
Crystal Ball provides two different ways for creating RNGs in spreadsheets Built-in CB functions Used in formulas like any other Excel function But require CB to be installed on the machine displaying the spreadsheet & do not support all CB functionality The Distribution Gallery Display a number (not a formula) in a cell but generates random numbers for that cell when simulating the model Does not require CB to be installed on the machine to display the spreadsheet & supports all CB functionality Both techniques useful in different situations
28
Some of the Built-in RNGs Provided By Crystal Ball
Distribution RNG Function Binomial =CB.Binomial(p,n) Custom =CB.Custom(range) Gamma =CB.Gamma(loc,shape,scale,min,max) Poisson =CB.Poisson(l) Continuous Uniform =CB.Uniform(min,max) Exponential =CB.Exponential(l) Normal =CB.Normal(m,s,min,max) Triangular =CB.Triang(min, most likely, max)
29
Using CB RNG Functions Click Insert Function icon Select CB option
Select RNG function
30
Using the Distribution Gallery
Click Define Assumption icon Select distirbution Specify parameters
31
Examples of Discrete Probability Distributions
32
Examples of Continuous Probability Distributions
33
Video Clips There are 2 video clips that will show you a step-by-step approach on how to generate random values using Crystal Ball’s distribution gallery and built-in functions. Now will be a good time to view them.
34
Discrete vs. Continuous Random Variables
A discrete random variable may assume one of a fixed set of (usually integer) values. Example: The number of defective tires on a new car can be 0, 1, 2, 3, or 4. A continuous random variable may assume one of an infinite number of values in a specified range. Example: The amount of gasoline in a new car can be any value between 0 and the maximum capacity of the fuel tank.
35
The Uncertainty of Sampling
The replications of our model represent a sample from the (infinite) population of all possible replications. Suppose we repeated the simulation and obtained a new sample of the same size. Q: Would the statistical results be the same? A: No! As the sample size (# of replications or number of simulated runs) increases, the sample statistics converge to the true population values. We can also construct confidence intervals for a number of statistics...
36
Constructing a Confidence Interval for the True Population Mean
where: Note that as n increases, the width of the confidence interval decreases.
37
Constructing a Confidence Interval for the True Population Proportion
where: Note again that as n increases, the width of the confidence interval decreases.
38
Crystal Ball Manual Please note that as a resource, I am Crystal Ball’s manual that may be used as a reference. The manual is in PDF format. Please focus on the following chapters from the manual: Chapter 1 Chapter 2 (up to page 31) Chapter 5 (up to page 113) Appendix A (review examples of the following distributions:
39
Commonly Encountered Distributions
Normal distribution Continuous uniform distribution Triangular distribution Binomial distribution Discrete uniform distribution Read other sections that may help you in understanding other issues related to Crystal Ball.
40
Other Thoughts Please follow the following guidelines to help
you in setting up problems in Crystal Ball. First determine what is the bottom line performance measure that we are trying to simulate (i.e., dependent variable). Next, determine what variables (i.e., independent variables) will affect the dependent variable.
41
Other thoughts (continued)
3. Next, determine the mathematical relationship between the dependent and independent variables 4. The dependent variable will always be designated as the “Forecast Cell” in Crystal Ball. 5. The distribution of the independent variables are typically designated from the Define Assumption gallery in Crystal Ball or using the built-in functions.
42
A Conceptual Example Assume that you are self-employed. Your monthly revenues range between $3000 to $ Assume that any revenue in this range will occur with equal likelihood. Moreover, assume that your costs in a given month are normally distributed with a mean of $2000 and a standard deviation of $500.
43
Example (continued) We would like to simulate monthly profits, and we need to replicate this experiment say 5000 times. Let’s employ the previous steps to model this problem in Crystal Ball. First, what is the dependent variable that resembles the bottom line performance measure: Answer: monthly profitability
44
Example (continued) What are the independent variables that will impact our monthly profitability: Answer: monthly revenues and costs Next, what is the mathematical relationship that links all these variables: Answer: Profit = Revenue – cost Next, in Crystal Ball you will first have to create this simple model in a spreadsheet.
45
Example (continued) Once your model is set up in a spreadsheet, you will need to click on the Define Assumption button from Crystal Ball’s tool menu to define the corresponding probability distribution of each independent variable. As stated in the problem, revenues will be designated as a continuous uniform distribution with a min of $3000 and a max of $4000.
46
Example (continued) Next, the variable “Cost” will be designated as a normally distributed variable with a mean of $2000 and a standard deviation of $500. Notice that once the distribution of each independent variable is specified, the designated cell will change colors to Green if it has been specified from the distribution gallery. If you specify the distribution as a built-in Crystal Ball function, the color will not change.
47
Example (continued) Next, you will need to designate the profit cell as a “forecast cell” by clicking on the Define Forecast button from Crystal Ball’s tool bar menu. Once you do that, the profit cell will change color to Blue. Now you are ready to run the simulation model! See a video clip of this example (Simulation Example 1) simulated in Crystal Ball.
48
Another Crystal Ball Example
Joe Smith is a handyman who owns his own plumbing business. In a typical month, the number of service calls that he gets varies according to the following distribution: No. of Calls Probability
49
Handyman Example (continued)
His revenues per service call are normally distributed with a mean of $100 and a standard deviation of $20. His monthly expenses can range between a minimum of $1000 and a maximum of $1500, where all values between the minimum and maximum can occur with equal likelihood.
50
Example (continued) a. Use Crystal Ball to simulate Mr. Smith’s monthly profits. Run 5000 replications of the model. b. What is the average monthly profit? Please try the above problem before viewing the ideal solution from the next slide:
51
Example (continued) The ideal solution is located in the file: Handyman_simulation_example. You must open this file from within Crystal Ball and not Excel! Please note that every time you simulate the problem, you will get slightly different results. This is natural as the Assumption variables values will change each time you run the simulation.
52
For example, think of tossing a coin 30 times
For example, think of tossing a coin 30 times. Say you got 14 heads and 16 tails. Are you going to get the exact same results if you repeat this experiment again? Most likely no! However, notice that if we toss this coin a very large number of times, statistical theory tells us that the probability of either heads or tails will be 50%. That's why when you run simulation experiments you need to run the experiment long enough (e.g., say 5000 trials or more).
53
Waiting Line Example The Excel file “simulation queue example” contains 3 worksheets named, Description, Model, and Solution, respectively. Please open this Excel file from within Crystal Ball to learn about how simulation may be employed in tackling queuing or waiting lines applications.
54
Final Thoughts You may notice that as you set up some of the simulation problems, the values of the random values will automatically change on you. This is a natural occurrence as Excel recalculates these values automatically. This should have no impact on your results.
55
End of Chapter 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.