A stochastic simulation is a
simulation
A simulation is an imitative representation of a process or system that could exist in the real world. In this broad sense, simulation can often be used interchangeably with model. Sometimes a clear distinction between the two terms is made, in ...
of a
system
A system is a group of interacting or interrelated elements that act according to a set of rules to form a unified whole. A system, surrounded and influenced by its open system (systems theory), environment, is described by its boundaries, str ...
that has variables that can change
stochastically (randomly) with individual probabilities.
[DLOUHÝ, M.; FÁBRY, J.; KUNCOVÁ, M.. Simulace pro ekonomy. Praha : VŠE, 2005.]
Realizations of these
random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a Mathematics, mathematical formalization of a quantity or object which depends on randomness, random events. The term 'random variable' in its mathema ...
s are generated and inserted into a model of the system. Outputs of the model are recorded, and then the process is repeated with a new set of random values. These steps are repeated until a sufficient amount of data is gathered. In the end, the
distribution of the outputs shows the most probable estimates as well as a frame of expectations regarding what ranges of values the variables are more or less likely to fall in.
Often random variables inserted into the model are created on a computer with a
random number generator (RNG). The U(0,1)
uniform distribution outputs of the random number generator are then transformed into random variables with probability distributions that are used in the system model.
Etymology
''
Stochastic Stochastic (; ) is the property of being well-described by a random probability distribution. ''Stochasticity'' and ''randomness'' are technically distinct concepts: the former refers to a modeling approach, while the latter describes phenomena; i ...
'' originally meant "pertaining to conjecture"; from Greek stokhastikos "able to guess, conjecturing": from stokhazesthai "guess"; from stokhos "a guess, aim, target, mark". The sense of "randomly determined" was first recorded in 1934, from German Stochastik.
Discrete-event simulation
In order to determine the next event in a stochastic simulation, the rates of all possible changes to the state of the model are computed, and then ordered in an array. Next, the cumulative sum of the array is taken, and the final cell contains the number R, where R is the total event rate. This cumulative array is now a discrete cumulative distribution, and can be used to choose the next event by picking a random number z~U(0,R) and choosing the first event, such that z is less than the rate associated with that event.
Probability distributions
A probability distribution is used to describe the potential outcome of a random variable.
Limits the outcomes where the variable can only take on discrete values.
[Rachev, Svetlozar T. Stoyanov, Stoyan V. Fabozzi, Frank J., "Chapter 1 Concepts of Probability" in Advanced Stochastic Models, Risk Assessment, and Portfolio Optimization : The Ideal Risk, Uncertainty, and Performance Measures, Hoboken, NJ, USA: Wiley, 2008]
Bernoulli distribution
A random variable X is
Bernoulli-distributed with parameter p if it has two possible outcomes usually encoded 1 (success or default) or 0 (failure or survival) where the probabilities of success and failure are
and
where
.
To produce a random variable X with a Bernoulli distribution from a U(0,1) uniform distribution made by a random number generator, we define
such that the probability for
and
.
= Example: Toss of coin
=
Define
For a fair coin, both realizations are equally likely. We can generate realizations of this random variable X from a
uniform distribution provided by a random number generator (RNG) by having
if the RNG outputs a value between 0 and 0.5 and
if the RNG outputs a value between 0.5 and 1.
Of course, the two outcomes may not be equally likely (e.g. success of medical treatment).
[Bernoulli Distribution, The University of Chicago - Department of Statistics, nlineavailable at http://galton.uchicago.edu/~eichler/stat22000/Handouts/l12.pdf]
Binomial distribution
A
binomial distributed random variable Y with parameters ''n'' and ''p'' is obtained as the sum of ''n'' independent and identically
Bernoulli-distributed random variables ''X''
1, ''X''
2, ..., ''X''
''n''
Example: A coin is tossed three times. Find the probability of getting exactly two heads.
This problem can be solved by looking at the sample space. There are three ways to get two heads.
The answer is 3/8 (= 0.375).
Poisson distribution
A poisson process is a process where events occur randomly in an interval of time or space.
The probability distribution for Poisson processes with constant rate ''λ'' per time interval is given by the following equation.
Defining
as the number of events that occur in the time interval
It can be shown that inter-arrival times for events is
exponentially distributed with a
cumulative distribution function (CDF) of
. The inverse of the exponential CDF is given by
where
is an
uniformly distributed random variable.
Simulating a Poisson process with a constant rate
for the number of events
that occur in interval