Simulation
There are multiple types of simulation:
- Monte Carlo - aggregate the results of a series of "one shot" experiments using random numbers.
- Discrete Time - perform an
-step random state transition, moving from one state to another in each step. - Continuous Time - system state is continuously evolved over time as a result of prescribed dynamics.
- Discrete Event - system state transitions are triggered by events occuring at discrete points in continuous time.
1. Discrete Event Simulation
A discrete event simulation (DES) generates a random sample path through a state transition system, with time delays associated with each state.
- There is a single global clock (virtual time).
- State transitions are triggered by events oredered on a virtual timeline.
- DES involves invoking events in time order, updating the state of the system, and scheduling new events. The state is unchanged between events.
The times between events are random variables with an associated distribution. To get a sample path, we need to sample these distributions.
1.1 Designing a DES
To design a simulation model, we need to:
- Identify the entities in the system that have to be modelled.
- Identify the model states (program state variables) - these specify where each entity is and what it is doing.
- Identify the event types, recalling each state transition is triggered by an event.
- For each event, specify how it changes the current state, and what new events need to be scheduled and what events need to be cancelled when it fires.
- Add code to accumulate measurements while the simulation is running.
- Add code to output results when the program terminates.
2. Output Analysis
- A non-terminating simulation seeks to model a system at equilibrium (steady state), where as
, for all states . - A terminating simulation models a system over a specified period during which there is no notion of equilibrium.
We focus on non-terminating simulations. Assume we are using a simulation to estimate some steady state performance measure. The initial state is typicaly fixed, so the initial probability distribution is different to the distribution after some time
To avoid initialisation bias, we can discard the initialization transient by resetting the measures after some warm-up time, or render long-enough to render any bias insignificant.
2.1 Confidence Intervals
Discrete event simulations are stochasitc, so outputs are random variables and an each an observation of some measure
- For large
and known , . - Unlike in statistics, we do not know
. However, we can generate many intervals using different simulations and conclude that wit h 95% confidence, the true lies in at least 95% of the intervals. - This is the 95% confidence interval for
.
2.1.1 Confidence Interval for Mean
For any desired coverage probability of
So, amongst all possible intervals, we might have obsered
2.1.2 Unknown Variance
When we measure a population, we dont know
Where
2.1.3 Applying to DES
Looking at a single simulation run, a wider confidence interval suggests more uncertainty. Howver, a narrow confidence interval can suggest if we could stop the simulation or not.
Running
Another approach is to run the model once, waiting for it to reach approximate equilibrium, and then divide the measurement into batches, with
If the covariances are
3. Distribution Sampling
Simulations depend on the ability to sample continuous random distributions. For a random variable (RV)
3.1 Inverse Transform Method
Suppose
3.2 Acceptance-Rejection Method
If
Steps:
- Let
be a sample from an RV whose density function is . - Generate a
sample, . - Let
. - If
(i.e., ), accept . Otherwise, reject it and start again.
The probability of accepting
3.3 Convolution Method
To sample a sum of independent RVs, sample them individually and then add the results.
3.4 Composition Method
Consider a discrete RV
- Pick an
with probability . - Sample from the density
.