You are on page 1of 44

Session #3

Agenda
Problem 2.4 Hoboken Police problem limited source
Show that GPSS Solution gets same result (done last week)
Class Problems 4.2 ( Java City)
Class Problem 4.7 (Ginos Pizza) Manual
Class Problem 4.7 (Ginos Pizza) Automatic with VLOOKUP & Function
Class Problems 4.3 (Geophone) Simulation with Excel
Manual
Automatic without Outstanding Inventory Rule
Automatic with Outstanding Inventory Rule (One Outstanding Order)
Class Problem 4.3 GPSS
Introduction to Probability & Statistics
Probability Mass and Density Functions
Cumulative Distribution Functions
Continuous Process Generators
Inverse Transform Method

Review Basic Single Server Model


M/M/1 Infinite Source, FCFS, ..
Poisson Arrivals Result in Exponential Inter -arrivals (& Vice Versa)
Text gives formulas for key statistics for several queuing cases
We derived mathematically P(n), and Lq for the Basic Single Server Case
We showed that Poisson Arrivals have exponential inter-arrival times dist.
Tonight we will introduce INVERSE transform method to derive CPG
Can use spreadsheets for simple queuing cases
More complex problems may require use of higher level simulation languages
We looked at a GPSS model for Basic Single Server case
We ran the GPSS model and plot the inter-arrival times, arrival rate distribution,
and queue statistics.
What distribution did the arrival rate have when we used the exponential interarrival distribution at the generate block?
We then looked at problems with s servers and finite sources.
We were given a formula for generating an exponentially distributed RV from a
uniform random numbers. Lets check it out with Excel now.

Class Problem 4.2


The manager of Cafe Java is trying to determine whether to hire
another cashier for the morning coffee rush hour. Does she need
one? Justify your answer using the simulation results obtained
from 5 customers (use the table below)! Use the following random
number streams:

Lets look at the spreadsheet

Class Problem 4-7


Gino Petralli is an enterprising businessman. He is in
the process of starting up a Pizzeria. Specifically, he
needs to know if 10 tables in his dining area is
enough. Further, he would like to ensure the average
time a party must wait for a table is less than 2
minutes. Do a manual simulation of
Ginos Pizzeria to determine
if the facility can meet Ginos
criteria with its current setup.
Assume there are 10 tables in
the pizzeria and at the beginning
of the simulation, 8 of the tables
are occupied.

Problem 4.7 (Ginos Pizza))

Interarrivals...

Interarrivals are exponentially


distributed with a mean of 1/ = 10
min/group. Thus, = 6 groups/hr.
This results in the following process
generator for interarrivals.

ln( r1 )
6

( 60 m in/ hr )

# in Group...

x=5
.10

Order Size...

x=6
.10

# in G roup
x=2
.20

x=4
.20

2
3
4
5
6

#of Pizzas
O rdered (x)
1
1 (or 2)
2
2 (or 3)
3 (or 4)

Consumption and conversation


time...
p(x)
1.00
.60 (.40)
1.00
.20 (.80)
.50 (.50)

This process is uniformly


distributed (a,b) where a=10
and b=50. The continuous
process generator for a
uniform distribution is...

x = r4(50 - 10) + 10

x=3
.40

C ooking Tim e...


The pizza oven is of the conveyor belt type. It
takes 10 m inutes to cook a pizza and pizzas
m ust be spaced 2 m inutes apart.

which generates eat times

Note: Also,
assume a 5
minute delay
between the time
a group is seated
until the time its
pizza(s) enters the
oven.

GINOs PIZZA Problem (4.7)

VLOOKUP & Function Approach for Queue Length


GPSS Solution

Class Problem 4-3

The commercial off the shelve (COTS) Program


Manager (PM) for the Seawolf class attack
submarine has asked you to exam their proposed
inventory policy for passive sonar geophones
(PSGs). The inventory policy must support the
Navys diverse missions. The proposed inventory
policy is to order 30 PSGs whenever the inventory
drops below 16 at the east coast depot.

Class Problem 4.3 Manual


Process Generator 1:
x = 5/6 ln(r1)

DEMAND (given)

exp inter-arrival time with lambda = 6/5 orders per day

i.e 1/lambda - 5/6 days per order Inter-arrival time avg. (IAT avg.)

Process Generator 2:

of

Number of PSGs in Order (Given)

Number
PSGs

Frequency

30

25

25

Continued
____

Class Problem 4.3


Process Generator 2: Number of PSGs
Number of PSGs
1
2
3
4
5
6

P(x)
0.06
0.05
0.09
0.3
0.25
0.25

Cum Prob
0.06
0.11
0.2
0.5
0.75
1

RN Range
0 <= r2 <.06
.06 <= r2 < .11
.11 <= r2 < .20
.20 <= r2 < .50
.50 <= r2 < .75
.75 <= r2 < 1.0

Process Generator 3: Y = - 12.5 ln(r3) Number Days Lead Time

Simulation Class Problem 4.3

r1

Days Between

Clock Time

r2

dem
and

r3

I
n
v
e
n
t
o
r
y

L
e
a
d
Ti
m
e

Orders

Place
Ord
er

Level
0

0.904

0.782

3.078

15

0.659

0.347526454

0.347526454

0.398

0.872

11

0.9

0.08780043

0.435326883

0.808

0.084

Yes

Order
arriv

3.07376

0.024

3.108084541

3.543411424

0.647

0.393

30

0.219

1.265569624

4.808981048

0.695

0.211

25

0.411

0.740968387

5.549949435

0.65

0.132

20

0.237

1.199745948

6.749695384

0.667

0.843

0.599

0.427078067

7.176773451

0.04

0.921

14

0.826

0.159300421

7.336073872

0.516

0.909

Order
arriv
es

2.1349

15

39

yes

8.88455

Problem 4.3 Excel Solution

EXCEL MANUAL
EXCEL Automatic Without No Outstanding Order Rule
EXCEL Automatic With Outstanding Order Rule

Geophone Problem with GPSS


Run GPSS For Geophone Problem Policy 2 (1 Outstanding
Inventory Order at a time)

f(x)
1
b-a

Introduction to
Probability and Statistics
Part I

b
b

b-a

f(x)dx = b - a 1
a

0.4

f(x)

0.3

Department of Systems Engineering


and Engineering Management
Charles V. Schaefer Jr. School of
Engineering
Stevens Institute of Technology
Hoboken, New Jersey 07030

N (0,1)

0.2
0.1
0
-4

-2

0
x

Lesson Objectives
Lesson Objectives
Probability & Statistics Review PDFs, CDFs, etc.
Role of Continuous Process Generators
Inverse Transform Method

Role of Statistics in Modeling and


Simulation

Uniform

Definitions

Probability

Population

Mythical - Exact
World

Sample

Statistics

Random - Real
World

Process Generators
Discrete Process Generators
Easier to explain and
understand

In many simulations, it is more


realistic and practical to use
continuous random variables
- Computational it is more efficient
- More representative of the
real world

Continuous Process Generators

Discrete Process Generators


1

Time
Between
Truck
Arrivals,
Hours

12

12
10

Frequency

0.75

8
6

0.50

4
0.25

2
0

0
20

10

30

0.5

0.25

0.75

1.0

Time Between Truck Arrivals, Hours

a. Sorted Observations

30/30

1.0

Cumulative
Probability

b. Histogram

24/30

0.8

21/30

Uniform
Random
Variable

Time Between
Truck Arrivals
(hours)

0.6
12/30

0.4
0.2
0
0

0.25

0.5

0.75

1.0

0
0.40
0.70
0.80

<
<
<
<

r
r
r
r

<
<
<
<

0.40
0.70
0.80
1.00

Time Between Truck Arrivals, Hours


c. Cumulative Distribution Function

d. Process Generator

0.25
0.50
0.75
1.00

Role of Statistics in Modeling and


Simulation
Frequency tables or histograms suppress much detail
Idealized mathematical representations are needed
real world is not discrete
mathematically efficient
The curve describing the shape of the distribution is called
a frequency curve
0.4

Area Under
Curve Must Be
Equal to 1

f(x)

0.3
0.2
0.1
0
5

Interarrival Time, Students/Hour

Probability & Statistics Review

Random Variable

Two types
Discrete
Continuous

Random Variable

Probability mass function


Discrete
P(X = xi) = p(xi)
p(xi) = 1

Random Variable

Probability density function


Continuous
f(x) = e x x > 0 (example)
P(X = a) = 0
- f(x) dx = 1
P(a < x < b) = ab f(x) dx

Probability Density Function

In mathematics, a probability density function (PDF)


serves to represent a probability distribution in terms of
integrals

If a probability distribution has density f(x):


The infinitesimal interval [x, x + dx] has probability f(x) dx
It can be seen as a "smoothed out" version of a histogram

24

Probability Density Function


Probability Density Function
p ( x ) 0 for all x

p(x)

p( x) 1

P(x a) 0
b

P (a x b)

p ( x ) dx area under
a

P ( x )

p ( x ) dx 1

p(x)

Random Variable

Cumulative distribution function (CDF)


F(X) = P(x <= X)

p ( x i ) D iscrete R V

xi X

f ( x ) dx C ontinuous R V

Cumulative Distribution Function


The cumulative distribution function (CDF) for a random
variable X is the probability that the random variable is less
than or equal to a specific value x

CDF

PDFdt
0

27

Random Variable

Expected value
= E(x)
= xi p (xi)
= x f(x) dx

Probability Density Function


Example

Probability Density Function


0.009
0.008
0.007
0.006
0.005
0.004
0.003
0.002
0.001
0
1

15

29

43

57

71

85

99 113 127 141 155 169 183 197 211 225 239 253 267 281 295

29

Cumulative Distribution Function


Example
Probability Density Function

PDF = f(t)

0.009
0.008
0.007
0.006
0.005
0.004
0.003
0.002
0.001
0
1

15

29

43

57

71

85

99 113 127 141 155 169 183 197 211 225 239 253 267 281 295

Cumulative Distribution Function


0.999843268881617

CDF

PDFdt
0

1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
1

18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 290

30

Some Useful
Continuous
Probability Distributions
Uniform Distribution
Triangular Distribution
Normal Distribution
Exponential Distribution

31

Continuous Distributions
Uniform Distribution

Discrete analogy of the continuous uniform distribution

Characterizes a random variable for which all integer outcomes between some
minimum value a and maximum value are equally likely

The density function is


if

f ( x ) 1 /( b a )

axb

and F(X) =

f(x)dx =

Mean = (a+b)/2

b-a
1
b-a

f(x)
1
b-a
a

32

Continuous Distributions
Triangular Distribution

Defined by three parameters: the minimum, a; maximum, b; and most likely, c

The density function is

2(x - a)
(b - a)(c - a)

if a<= x <= c

2(b - x)
(b - a)(b - c)

if c< x <= b

f(x)

otherwise

The mean is computed as (a+b+c)/3

33

Random Variable

Variance

V ( x ) E [( x ) ]
2

E[x
E

2 x

x ( E ( x ))
2

2
i

p ( xi )

( x i p ( x i ))

Random Variable

Standard deviation

SD ( X )

V (X )

Sums of R.V.

Y a 1 x1 a 2 x 2
E ( y ) a 1 E ( x1 ) a 2 E ( x 2 )
2

V (Y ) a 1 V ( x1 ) a 2 V ( x 2 )
when x1 and x2 are independent random variables

Random Variable

SampleMean

Xi

n
SampleVari ance

(X

X)

n 1

2
i

n 1

Continuous Process Generators


AS IN THE DISCRETE METHOD, WE
FIRST GENERATE A U(0,1) RANDOM
NUMBER AND THEN TRANSFORM IT
INTO A RANDOM VARIATE FROM THE
SPECIFIED DISTRIBUTION.
Two methods to transform:
- Inverse Transformation Method
- Acceptance-Rejection Method

Continuous Process Generators


The ITM is generally used for
distributions whose cumulative
distribution function can be obtained
in closed form.
STEP 1: Obtain CDF from PDF
(interject X into the equation)
STEP 2: Set F(x) = r
STEP 3: Solve for x
(as a function of r)
We did this last week for the exponential distribution of arrival times

IVT for Uniform Distribution


U N IF O R M [ a .b ]
C heck this is a pdf

p(x)

p( x)

dx / ( b a )

x / ( b a )] a b / ( b a ) a / ( b a ) 1
b

h=1/(b-a)

and p ( x ) 0
p ( x ) is thus a pdf

L et ' s find C D F
X

F (t )

f ( t ) dt

dt / ( b a ) t / ( b a )]

X
a

( x a ) / (b a )

L et ' s find C P G
r F ( x ) ( x a ) / (b a )
r (b a ) ( x a )
x a r (b a )

Converts uniform random numbers from U(0,1) to values of the random with distribution U(a,b)

Upper Ramp Example

2/(b-a)

(b,2/(b-a))

Show p(x) is a pdf:


p ( x ) 2( x a ) / (b a )

P(x)

p ( x ) dx

2 ( x a ) dx / ( b a )

2 / (b a )

( x a ) dx
a

2
2
2 / ( b a ) [ x / 2 ax ] 0 (2 r/ (b1 a ) )[ b / 2 ab a / 2 a ]
2

h 2 / (b a )

b
a

(1 / ( b a ) )[ b 2 ab a 2 a ] ( 2 / ( b a ) [ b 2 ab a ] ( b a ) / ( b a )
2

1, p ( x ) is G E 0, p ( x ) is a p robability distribution

Find CDF & CPG:

y 1 ( b , 2 / ( b a ))
y0 (a , 0)
m ( 2 / ( b a )) / ( b a ) 2 / ( b a )

p ( x ) ( 2 / ( b a ) )( x a )
2

f (t ) 2(t a ) / (b a )
x

F (x)

f ( t ) dt

2(t a ) / (b a )

2 / ( b a ) [ t / 2 at ] a
2

2 / ( b a ) [ x / 2 ax a / 2 a ] r
2

Substituting h=2/(b-a):

=CDF

r h / ( b a )[( x / 2 ) ax a / 2 ]
2

2 ( b a ) r / h x 2 ax a ( x a )
2

( x a ) 2(b a )r / h

x a

2(b a )r / h

for 0 r 1

=CPG

Continuous Process Generators


Distribution

Diagram

Uniform

PDF

f(x) = b - a
0

axb

x-a

F(x) = b - a
O therw ise
0

Ramp - up

2(x - a)

2
f(x) = (b - a)
0

Process
Generator

CDF

axb
O therw ise

(x - a) 2

2
F(x) = (b - a)
0

axb
Otherwise

axb

x = a + (b - a)r
0 r1

xa

2 r (b a )
h

O therw ise

0 r 1

Continuous Process Generators

Distribution

Diagram

Ramp-Up
&
Ramp Down

A
a

PDF

2(x - a)
(b - a)(m - a) a x m

2(b - x)
f(x) =
mxb
(b - a)(b - m )
0
O therw ise

CDF

(x - a) 2
axm

(b - a)(m - a)

(b - x)
f(x) = 1
mxb
(b - a)(b - m )
0
O therw ise

Process
Generator

x = a+ r(b-a)( m a )
0 r ( m a ) / (b a )
x = b- (1-r)(b-a)(b m )
( m a ) / (b a ) r 1

A=1/2base*height=(m-a)*(2/b-a)/2
= (m-a)/(b-a)

Continuous Process Generators

Distribution

Diagram

Ramp - Down

Exponential

PDF

2(b - x)

2
f(x) = (b - a)
0

e - x
f(x) =
0

CDF

a x b
O therw ise

x 0, 0
Otherwise

(b - x) 2
axb
1
2
(b - a)
F(x) =
0
O therw ise

1 - e - x
x0
F(x) =
O therw ise
0

Process
Generator

x = b - (b - a) (1 r )
2

0 r1

x = 0 r1

ln r

Questions?

You might also like