Sampling from Discrete Probability Distributions

advertisement
Modeling & Simulation- Lecture -7-
12/2012
Sampling from Discrete Probability Distributions
A)
Sampling from Poisson Distribution
The Poisson distribution is used to model a random number of events that will
occur in an interval of time. The Poisson distribution has only one parameter, λ. This
distribution is unique in that the mean and variance are both equal to λ. Figure (1)
shows the Poisson distribution. The probability density function is:
( )
( ⁄ )
One method for generating Poisson variants involves the generation of exponentially
distributed time intervals , , ,... with an expected value equal to 1/λ. These
intervals are accumulated until they exceed 1, the unit time period. That is,
∑
∑
The stochastic variant n is simply the number of events occurred during a unit time
period. Now, since
, n can be obtained by simply summing up random
numbers until the sum for n+1 exceeds the quantity
following expression:
∑
∑
. That is, n is given by the
…………..((6))
Figure (1) the Poisson distribution
1
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -7-
12/2012
B)
Sampling from a geometric distribution
Let and
be the probability of a success and failure respectively. The
( )
probability density function of the geometric distribution is:
And its cumulative probability density function is: ( ) ∑
The expectation and the variance are:
( )
( )
And the random variant can be generated as follows:
Since
And
we have that:
( )
( )
∑
we obtain that:
( )
( ) between 0 and 1 then:
(
)
……………..((7))
C)
Sampling from Binomial Distribution
The probability density function of the binomial distribution is:
( )
( )
The expectation and the variance are :
( )
( )
We can generate variants from a binomial distribution with a given p and n as follows.
We generate n random numbers, after setting a variable
equal to zero. For each
random number , i=1, 2... n, a check is made, and the variable
is incremented as
follows:
{
The final quantity
2
……………..((8))
is the binomial variant.
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -7-
12/2012
Entities, Attributes & Activities
An entity is an object of interest in the system: customer, manager, and cashier.
An attribute is a (relevant) property of an entity: account balance, gender, skills
Attributes are state variables.
Activities & Delays
An activity: is duration of known length: check balance, drink coffee, serve customer.
Activities form part of the model specification
A delay: is duration of unknown length: Waiting time in queue,
Delays form part of the simulation result.
State, State Variables
The system state: is a description which is -complete and - minimal at any point in
time
A state variable: is a variable needed to describe the state: length of queue (0, 1, 2 ...),
current activity of manager (sleeping, drinking coffee ...).
Events
An event: is an occurrence which is instant may change the state of the system
Service is completed, Customer arrives from outside.
Model Specification
 Discrete-event modeling raises the following questions: How does each event
affect the system state and attributes?
 How are activities defined? What events mark the beginning and the end?
 What conditions (if any) must hold? How are delays defined?
 How must the simulation be initialized?
Event Notice, Event List
Event notice: A data record specifying an event
The event notice must contain all the information necessary to execute the event (in
particular the time it is scheduled to occur)
(Future) event list: A list of event notices for future events
The event list is the main data structure in a discrete-event simulator
3
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -7-
12/2012
The Event List
The (future) event list (FEL) controls the simulation
The FEL contains all future events that are scheduled
The FEL is ordered by increasing time of event notice
Example FEL (at some simulation time ≤ t):
Conditional and Primary Events
A primary event: An event whose occurrence is scheduled at a certain time Arrivals
of customers.
A conditional even: An event which is triggered by a certain condition becoming true
Customer moving from queue to service.
Timing
Sometimes, activities last for an exact amount of time:
– The clock cycle in a computer
– Each phase of a traffic light
– A certain operation in a manufacturing line
Such exact times are deterministic.
4
Lecturer: Hawraa Sh.
Modeling & Simulation- Lecture -7-
12/2012
Usually, activities last for varying amounts of time:
– Inter-arrival times at bank
– Service times at bank
– Time to failure for a machine
– Time that a user program runs
Such times are random stochastic.
Two mechanisms to advance the simulated time:
Next-event time advance: The simulation clock is always advanced to the time of the
next event, the state variables are updated and future event times are determined, until
termination.
Fixed-increment time advance: The simulation clock is always advanced in increments
of ∆t time units.
5
Lecturer: Hawraa Sh.
Download