Jump to content

User:StevenJYang/Stochastic simulation

From Wikipedia, the free encyclopedia

A stochastic simulation is a simulation of a system that has variables that can change stochastically (randomly) with individual probabilities. Realizations of these random variables 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 used in simulations are created on a computer with a random number generator (RNG). RNGs on computers can be either a pseudo-random number generator or a hardware random number generator. Both of these random number generators output realizations of the uniform distribution U(0,1) where all intervals of equal length between zero and one are equally probable. The outputs of the random number generator are then transformed into random variables with probability distributions that are used in the system model.

Probability distributions

[edit]

Bernoulli distribution

[edit]

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)[1] 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 forand .

Example: Toss of coin
[edit]

Define

X = 1 if head comes up and
X = 0 if tail comes up

For a fair coin, both realizations are equally likely. We can generate realizations of this random variable X from a U(1,0) uniform distribution provided by a random number generator (RNG) by having X = 1 if the RNG outputs a value between 0 and 0.5 and X = 0 if the RNG outputs a value between 0.5 and 1.

P (X = 1) = P(0 ≤ U < 1/2) = 1/2
P (X = 0) = P(1 ≥ U ≥ 1/2) = 1/2

Of course, for other systems, the two outcomes may not be equally likely (e.g. unfair coin, success of medical treatment).

Binomial distribution

[edit]

Main article: 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 X1, X2, ..., Xn

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.

HHH, HHT, HTH, THH, TTH, THT, HTT, TTT

The answer is 3/8 (= 0.375).

Poisson distribution

[edit]

Main article: Poisson distribution

A poison process is a process where events occur randomly in 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 the probability distribution of events that occur before time is given by

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 up to time can be carried out with the following algorithm.[2]

  1. Begin with and
  2. Generate random variable from uniform distribution
  3. Update the time with
  4. If , then stop. Else continue to step 5.
  5. , and
  6. Continue to step 2






The Poisson distribution depends on only one parameter, λ, and can be interpreted as an approximation to the binomial distribution when the parameter p is a small number. A poisson-distributed random variable is usually used to describe the random number of events occurring over a certain time interval.

Typical example problem: If 3% of the electric bulbs manufactured by a company are defective find the probability that in a sample of 100 bulbs exactly 5 bulbs are defective. ( Given e-0.25= 0.7788 )



  1. ^ Rachev, Svetlozar T.; Stoyanov, Stoyan V.; Fabozzi, Frank J. (2011-04-14). "A Probability Metrics Approach to Financial Risk Measures". doi:10.1002/9781444392715. {{cite journal}}: Cite journal requires |journal= (help)
  2. ^ Sigman, Karl. "Poisson processes, and Compound (batch) Poisson processes" (PDF).{{cite web}}: CS1 maint: url-status (link)