0% found this document useful (0 votes)
14 views33 pages

Fundamentals of Simulation in Ms Excel / Monte Carlo Simulation

Chapter 3 covers the fundamentals of simulation in MS Excel, focusing on Monte Carlo simulation and random number generation. It explains how to simulate randomness, generate random numbers using Excel functions, and apply these concepts in practical examples such as coin tossing and service time simulations. The chapter also outlines the steps for conducting simulations and provides insights into performance measures and system outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views33 pages

Fundamentals of Simulation in Ms Excel / Monte Carlo Simulation

Chapter 3 covers the fundamentals of simulation in MS Excel, focusing on Monte Carlo simulation and random number generation. It explains how to simulate randomness, generate random numbers using Excel functions, and apply these concepts in practical examples such as coin tossing and service time simulations. The chapter also outlines the steps for conducting simulations and provides insights into performance measures and system outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

CHAPTER 3

FUNDAMENTALS OF SIMULATION IN MS EXCEL


/ MONTE CARLO SIMULATION

Prof. Dr. Nezir AYDIN


Yıldız Technical University
Industrial Engineering

1
FUNDAMENTALS OF SIMULATION IN MS EXCEL (1/6)

• How to simulate randomness?


• Almost all of simulation models we cover in this section include
one or more random variable (For instance: simulating coin
tossing)

• How to gather random quantity? Random number and random


variable will be studied in detail in this course.

• First we will study gathering random quantities either in excel


or manually.

2
FUNDAMENTALS OF SIMULATION IN MS EXCEL (2/6)

• How to simulate randomness?


• Generating any random quantities begins with generating a
random number in the interval from 0 to 1.
• The term “random number” always refers to a randomly
generated quantity in the unit interval between 0 and 1.
• In contrast, the term “random variable” refers to any randomly
generated quantity with a specified statistical distribution.
• Any method for generating a sequence of random numbers is
called a Random Number Generator (RNG)

3
FUNDAMENTALS OF SIMULATION IN MS EXCEL (3/6)

• Random number generation


• The generation method for random numbers should
produce a sequence of numbers that have two
important statistical properties:
• The numbers should be uniformly distributed between 0 and
1.
• The subsequent numbers generated should be statistically
independent of all previous numbers generated. Having a
number will not help generating the next one.

4
FUNDAMENTALS OF SIMULATION IN MS EXCEL (4/6)

• Random number generation


• Generation usually done mathematically instead of
physically.
• Physically generated numbers are real random
numbers. Mathematically generated numbers are
pseudo-random numbers.
• Dice rolling, roulette, picking cards generate real
numbers but they are so slow.
• Usually, computers are used and numerical methods
are preferred. Therefore, they are called pseudo-
random numbers
5
FUNDAMENTALS OF SIMULATION IN MS EXCEL (5/6)

• How do we generate random numbers?


• Physical generators (Dice rolling, roulette, picking
cards)
• Algorithms (recurrence algorithm: a ‘seed’ number is
defined and random number is generated using that
‘seed’ and then newly generated number becomes the
‘seed’ for the next number to be generated)
• Existing random number tables (already generated
numbers)
• Simulation softwares
• General purpose languages.
6
FUNDAMENTALS OF SIMULATION IN MS EXCEL (6/6)

• Random number generation


• Real systems’ stochastic behavior can not be defined by
uniform distribution.
• It usually is defined by other theoretical distributions
(exponential, normal, gamma…).
• Therefore uniformly generated, between [0,1], number
need to be transformed to other theoretical distributions.
• With an appropriate technique this transformation can be
done.
• This process is exactly the same as sampling statistically
from a distribution.
• For this process the parameters of the distribution need
to be provided beforehand.

7
MONTE CARLO SIMULATION (1/2)

• It is named from Monte Carlo, which is a county


in Monaco and a famous city for gambling.
• Die rolling: You know one of the 1,2,3,4,5 or 6
will be thrown but which one?
• This is exactly as the same as Monte Carlo
Simulation process.
• The first Monte Carlo simulation is done in 1940
for the project Manhattan to estimate the effects
of nuclear explosion.

8
MONTE CARLO SIMULATION (2/2)

• Monte Carlo technique is to withdrawn random


numbers from a probability function to use in
simulation.
• U(0,1), Uniform distribution is used in simulation
where time is not the case or for deterministic
problems. Monte Carlo simulation is usually used for
static simulation models.
• Some authors define Monte Carlo simulation as a
simulation which uses random numbers.

9
RANDOM NUMBER GENERATION in MS EXCEL

• How do we generate random numbers in MS


Excel?
Ms Excel generates numbers with:
• =RAND() between 0-1,
• =IF(RAND()<=0.5,1,0) one of these numbers
• =RANDBETWEEN(a;b) between two numbers,
• Visual Basic (VBA)

10
=RAND(), =RANDBETWEEN()

11
Application.Calculation
=xlManual

Application.Calculation
=xlAutomatic

12
=RAND(), =IF(RAND()<=0.5,1,0)
• Coin Tossing:
• A coin (0.5 probability) is tossed 10 times.
• It is a Monte-Carlo simulation because there is no event
or simulation time.

• Example 2.1CoinToss.xls:
• There are 4 solutions.
• Solution#1A and Solution#1B use =RAND(),
• Solution#2A and Solution#2B use Rnd01() (VBA code)

13
VBA Functions
• Random service time simulation:
• On average service times at a call center occure as
3mins, 6mins or 10mins.
• The percentage of these calls are 30%, 45% or 25%.
• Simulate calls for 25 calls.

14
VBA Functions

• Total probability is 1.
• Lets say random numbers are determined as:
0.9871, 0.026, 0.0008, 0.2128, 0.8586
• What are the service times???

15
VBA Functions
Example2.2 ServiceTimes.xls:
• VBA function: DiscreteEmp().
• =IF(Rnd01()<=0.30, 3, IF(Rnd01()<=0.75,
6), 10) ???
=DisceretEmp($D$7:$D$9, $B$7:$B$9)

Which excel function can be used instead of


VBA function?

16
VBA Functions
Random interarrival time simulations:
Lets say interarrival time between two consecutive arrivals are 1,
2, 3, and 4 with equal probability for the previous example
(Uniform).

Then, lets simulate for 25 calls!

This example is a dynamic event which includes only one event.

• Example2.3 ArrivalTimes.xls:
• In this example, even VBA in the previous example could be
used, a macro for discrete uniform distribution is developed:
DiscreteUniform().

• Minimum value – Maximum value.

17
Simulation Steps in MS Excel (1/4)
The structure of each table is different, because it is problem structure
sensitive. However, the column of the tables can be generated as
follows:
Before developing the table, first determine the characteristics of each
of the inputs to the simulation. Quite often, these are modeled as
probability distributions, either continuous or discrete.
Each column in the table is one of the following:
• An activity time associated with model input
• Any other random variable defined by a model input (for
instance: probability of heads or tails in coin tossing game,
interarrival times)
• A system state (FI: state of the server – busy, idle )
• An event, or the clock time of an event
• A model output (FI: waiting time of each customer time in the
line)
• A model response - performance measures (FI: overall, average
waiting time)

18
Simulation Steps in MS Excel (2/4)
Usually, the following steps are followed to run a
simulation model manually or in excel:

Step 1: Define the characteristics (parameters of the


distributions) of the inputs.

Step 2: Determine activities, events, system state


variable.

Step 3: Determine the performance measures.

Step 4: Determine outputs needed to calculate


performance measures.
19
Simulation Steps in MS Excel (3/4)
Step 5: A Generic simulation Table.
Let there are p inputs, xij, j = 1,2,... ,p, (activity) and one response, Yi,
for each of repetitions (or, trials) i = 1,2, . . . , n.

Step Activities and system states Output

xi1 xi2 xi3 … xij… .xip yi

20
Simulation Steps in MS Excel (4/4)
Step 6: Initialize the table by filling in the data for
repetition 1. For each repetition i, generate a value for each
of the p inputs, and evaluate the function, calculating a
value of the response Yi.

Step 7: A response typically depends on the inputs and


one or more previous responses. Calculate performance
measures.

21
Monte-Carlo Simulation in MS Excel (1/9)
• In the table the sales data of a laptop for 100 weeks is
provided. (Sales price is $4300).

Demand(Weekly) Frequency Probability Step 1


0 25 25/150=0,167
1 75 75/150=0,5
2 25 25/150=0,167
3 15 15/150=0,1
4 10 10/150=0,06
Total 150 1

22
Monte-Carlo Simulation in MS Excel (2/9)

23
Monte-Carlo Simulation in MS Excel (3/9)
• State variable of the system is weekly demand. Step 2
• The demand for n=15 weeks (i=1, 2,…, 15) is
xij ( j = 1) is going to be determined via a simulation study.
• The probability of demand is shown as a roulette table
below:

24
Monte-Carlo Simulation in MS Excel (4/9)
• The random number for each demand can be converted
to a table as:

25
Monte-Carlo Simulation in MS Excel (5/9)

Step 3

• At the end of the study the average weekly demand


(demand/week) and weekly revenue ($/week) are wanted
to be calculated. (performance measures).
Step 4

• To determine performance measures revenue for each


week must be determined first.
• (System output, yi , i = 1, 2,...,15) )

26
Monte-Carlo Simulation in MS Excel (6/9)

Step 5

27
Monte-Carlo Simulation in MS Excel (7/9)
Step 6

Step 7
• Average demand=31/15=2.07 piece/week
• Average revenue=$133,300/15 = $8,886.67/week
28
Monte-Carlo Simulation in MS Excel (8/9)

29
Monte-Carlo Simulation in MS Excel (9/9)

Use Freeze
option under
View button

30
Scenario 1: Weekly 1 production (shortage cost
is $500 and inventory cost is $50)

31
Scenario 2: Weekly 2 production(shortage cost
is $500 and inventory cost is $50)

32
See you next lecture ☺

33

You might also like