Upload
twiddleap
View
221
Download
0
Embed Size (px)
Citation preview
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
1/44
Session #3 Agenda
Problem 2.4 Hoboken Police problem limited sourceShow that GPSS Solution gets same result (done last week)
Class Problems 4.2 ( Java City)Class Problem 4.7 (Ginos Pizza) ManualClass Problem 4.7 (Ginos Pizza) Automatic with VLOOKUP & Function
Class Problems 4.3 (Geophone) Simulation with ExcelManual Automatic without Outstanding Inventory Rule Automatic with Outstanding Inventory Rule (One Outstanding Order)
Class Problem 4.3 GPSSIntroduction to Probability & Statistics
Probability Mass and Density FunctionsCumulative Distribution Functions
Continuous Process GeneratorsInverse Transform Method
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
2/44
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 casesWe derived mathematically P(n), and Lq for the Basic Single Server CaseWe 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 casesMore complex problems may require use of higher level simulation languagesWe looked at a GPSS model for Basic Single Server caseWe 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 inter-arrival 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 auniform random numbers. Lets check it out with Excel now .
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
3/44
Class Problem 4.2
The manager of Cafe Java is trying to determine whether to hireanother cashier for the morning coffee rush hour. Does she needone? Justify your answer using the simulation results obtainedfrom 5 customers (use the table below)! Use the following randomnumber streams:
Lets look at the spreadsheet
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
4/44
Class Problem 4-7
Gino Petralli is an enterprising businessman. He is inthe process of starting up a Pizzeria. Specifically, heneeds to know if 10 tables in his dining area isenough. Further, he would like to ensure the averagetime a party must wait for a table is less than 2minutes. Do a manual simulation ofGinos Pizzeria to determineif the facility can meet Ginoscriteria with its current setup.
Assume there are 10 tables inthe pizzeria and at the beginningof the simulation, 8 of the tablesare occupied.
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
5/44
Interarrivals... # in Group... Order Size... Consumption and conversationtime...
Interarrivals are exponentiallydistributed with a mean of 1/ = 10min/group. Thus, = 6 groups/hr.This results in the following processgenerator for interarrivals.
xr
hr ln ( )
( min/ )16
60
=4
.20
=3
.40
=2.20
=5
.10
=6
.10
#of Pizzas# in Group Ordered (x) p(x)
2 1 1.00 3 1 (or 2) .60 (.40) 4 2 1.00 5 2 (or 3) .20 (.80) 6 3 (or 4) .50 (.50)
Cooking Time...
The pizza oven is of the conveyor belt type. Itakes 10 m inutes to cook a pizza and pizzasust be spaced 2 minutes apart.
This process is uniformlydistributed (a,b) where a=10and b=50. The continuous process generator for auniform distribution is...
x = r 4(50 - 10) + 10
which generates eat times
Note: Also,assume a 5minute delay between the timea group is seateduntil the time its pizza(s) enters theoven.
Problem 4.7 (Ginos Pizza) )
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
6/44
GINOs PIZZA Problem (4.7)
VLOOKUP & Function Approach for Queue LengthGPSS Solution
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
7/44
Class Problem 4-3
The commercial off the shelve (COTS) ProgramManager (PM) for the Seawolf class attacksubmarine has asked you to exam their proposedinventory policy for passive sonar geophones(PSGs). The inventory policy must support the
Navys diverse missions. The propo sed inventorypolicy is to order 30 PSGs whenever the inventorydrops below 16 at the east coast depot.
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
8/44
Class Problem 4.3 ManualProcess Generator 1: DEMAND (given)
x = 5/6 ln(r1) 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: Number of PSGs in Order (Given)
Numberof PSGs Frequency
1 6
2 5
3 9
4 30
5 25
6 25
Continued ____
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
9/44
Class Problem 4.3
Number of PSGs P(x) Cum Prob RN Range1 0.06 0.06 0
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
10/44
Simulation Class Problem 4.3
r1 Days Between Clock Time r2demand r3
Le
adTime
Inve
ntor y
PlaceOrder
Orders Level
0 0.904 6 0.782 3.078 15 Yes
0.659 0.347526454 0.347526454 0.398 4 0.872 11
0.9 0.08780043 0.435326883 0.808 6 0.084 5
Orderarriv 3.07376
0.024 3.108084541 3.543411424 0.647 5 0.393 30
0.219 1.265569624 4.808981048 0.695 5 0.211 25
0.411 0.740968387 5.549949435 0.65 5 0.132 20
0.237 1.199745948 6.749695384 0.667 5 0.843 2.1349 15 yes
0.599 0.427078067 7.176773451 0.04 1 0.921 14
0.826 0.159300421 7.336073872 0.516 5 0.909 9
Order
arrives 39 8.88455
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
11/44
Problem 4.3 Excel Solution
EXCEL MANUALEXCEL Automatic Without No Outstanding Order RuleEXCEL Automatic With Outstanding Order Rule
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
12/44
Geophone Problem with GPSS
Run GPSS For Geophone Problem Policy 2 (1 OutstandingInventory Order at a time)
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
13/44
Department of Systems Engineeringand Engineering ManagementCharles V. Schaefer Jr. School ofEngineeringStevens Institute of TechnologyHoboken, New Jersey 07030
Introduction toProbability and Statistics
Part I
0
0 .1
0 .2
0 .3
0 .4
-4 -2 0 2 4
x
f (
x )
N (0 ,1 )
a b x
f(x)
1 b - a
f(x)dx = b - a
b - a1
a
b
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
14/44
Lesson Objectives
Lesson ObjectivesProbability & Statistics Review PDFs, CDFs, etc. Role of Continuous Process Generators Inverse Transform Method
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
15/44
Role of Statistics in Modeling andSimulation
Uniform
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
16/44
Definitions
Population Sample
Mythical - ExactWorld
Random - RealWorld
Probability
Statistics
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
17/44
Process Generators
Continuous Process Generators
In many simulations, it is morerealistic and practical to usecontinuous random variables
- Computational it is more efficient- More representative of the
real world
Discrete Process Generators
Easier to explain andunderstand
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
18/44
Discrete Process Generators
0
2
4
6
8
10
12
Frequency
b. Histogram
0 0.5 1.00.250
0.25
0.50
0.75
1
a. Sorted Observations
12
9
3
6
TimeBetween
TruckArrivals,
Hours
0
0.4
0.8
1.0
Cumulative
Probability
c. Cumulative Distribution Function
0 0.5 1.00.25
0.75
0.75
0.2
0.6
Uniform Time BetweenRandom Truck Arrivals
Variable (hours)
0 < r < 0.40 0.250.40 < r < 0.70 0.500.70 < r < 0.80 0.750.80 < r < 1.00 1.00
d. Process Generator
Time Between Truck Arrivals, Hours
12/30
21/3024/30
30/30
Time Between Truck Arrivals, Hours
10 20 30
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
19/44
Role of Statistics in Modeling andSimulation
Frequency tables or histograms suppress much detailIdealized mathematical representations are needed
real world is not discrete mathematically efficient
The curve describing the shape of the distribution is calleda frequency curve
0
0.1
0.2
0.3
0.4
5 6 7 8 9
Interarrival Time, Students/Hour
f (
x )
Area UnderCurve Must Be
Equal to 1
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
20/44
Probability & Statistics Review
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
21/44
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
22/44
Random Variable
Probability mass functionDiscrete
P(X = x i) = p(x i)
p(x i) = 1
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
23/44
Random Variable
Probability density functionContinuousf(x) = e x x > 0 (example)P(X = a) = 0
- f(x) dx = 1P(a < x < b) = a b f(x) dx
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
24/44
Probability Density Function
In mathematics, a probability density function (PDF)serves to represent a probability distribution in terms ofintegrals
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
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
25/44
Probability Density Function
Probability Density Function
( ) 0
( ) 1
p x fo r a ll x
p x
( ) 0
( ) ( ) ( )
( ) ( ) 1
b
a
P x a
P a x b p x dx area under p x
P x p x dx
a b
p(x)
x
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
26/44
Random Variable
Cumulative distribution function (CDF)
F(X) = P(x
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
27/44
Cumulative Distribution Function
The cumulative distribution function (CDF) for a randomvariable X is the probability that the random variable is lessthan or equal to a specific value x
x
PDFdt CDF
0
27
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
28/44
Random Variable
Expected value
= E(x)= xi p (x i)= x f(x) dx
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
29/44
Probability Density FunctionExample
Probability Density Function
0
0.001
0.002
0.0030.004
0.005
0.006
0.007
0.008
0.009
1 15 29 43 57 71 85 99 113 127 141 155 169 183 197 211 225 239 253 267 281 295
29
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
30/44
Cumulative Distribution FunctionExample
Probability Density Function
0
0.001
0.002
0.003
0.004
0.005
0.006
0.007
0.008
0.009
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
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1 18 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 290
0.999843268881617
x
PDFd t CDF
0
PDF = f(t)
30
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
31/44
Some UsefulContinuous
Probability Distributions
Uniform Distribution
Triangular Distribution
Normal Distribution
Exponential Distribution
31
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
32/44
Continuous Distributions
)/(1)( ab x f
Discrete analogy of the continuous uniform distribution
Characterizes a random variable for which all integer outcomes between someminimum value and maximum value are equally likely
The density function is
if
and F(X) =
Mean = (a+b)/2
Uniform Distribution
b xa
a b x
f(x)
1b - a
f(x)dx =b - ab - a
1a
b
32
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
33/44
Continuous Distributions
Triangular Distribution
33
Defined by three parameters: the minimum, a; maximum, b; and most likely, c
The density function is
2(x - a) if a
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
34/44
Random Variable
Variance
))((
))((2
2
22
22
2
)(
]2[
])[()(
x p x x
x E x
ii xi p
E
x x E
x E xV
i
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
35/44
Random Variable
Standard deviation
Sums of R.V.
when x 1 and x 2 are independent random variables
)()( X V X SD
)()()(
)()()(
2
2
21
2
1
2211
2211
xV a xV aY V
x E a x E a y E
xa xaY
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
36/44
Random Variable
n
X X SampleMean
i
11
)(222
2 n
n
n
X X anceSampleVari x xS
ii
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
37/44
Continuous Process Generators
AS IN THE DISCRETE METHOD, WEFIRST GENERATE A U(0,1) RANDOMNUMBER AND THEN TRANSFORM ITINTO A RANDOM VARIATE FROM THE
SPECIFIED DISTRIBUTION.
Two methods to transform:- Inverse Transformation Method- Acceptance-Rejection Method
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
38/44
Continuous Process Generators
The ITM is generally used fordistributions whose cumulativedistribution function can be obtainedin 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
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
39/44
IVT for Uniform Distribution
[ . ]
( ) / ( ) / ( ) ] / ( ) / ( ) 1
( ) 0
( )
'
( ) ( ) / ( ) / ( )] ( ) / ( )
'
( ) ( ) / ( )
b
a
X X
X a
a
U N IF O R M a b
Check this is a pdf
p x dx b a x b a b b a a b a
and p x
p x is th us a pdf
Let s find CD F
F t f t dt d t b a t b a x a b a
Let s find CP 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)
h=1/(b-a)
p(x)
a b
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
40/44
Upper Ramp Example
2
2 2
2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
( ) 2 ( ) / ( )
( ) 2 ( ) / ( ) 2 / ( ) ( )
2 / ( ) [ / 2 ] (2 / ( ) )[ / 2 / 2 ]
(1 / ( ) )[ 2 2 ] (2 / ( ) [ 2 ] ( ) / ( )
1, ( ) 0, ( )
b b
a a
ba
p x x a b a
p x dx x a dx b a b a x a dx
b a x ax b a b ab a a
b a b ab a a b a b ab a b a b a
p x is G E p x is a p
robabi li ty dis tr ibution
1
0
2
2
2 / ( )
( , 2 / ( ))
( , 0 )
(2 / ( )) / ( ) 2 / ( )
( ) (2 / ( ) )( )
h b a
y b b a
y a
m b a b a b a
p x b a x a
ab
2/(b-a) (b,2/(b-a))
P(x)
2
2 2 2
2 2 2 2
2 2
2 2 2
2
( ) 2 ( ) / ( )
( ) ( ) 2 ( ) / ( ) 2 / ( ) [ / 2 ]
2 / ( ) [ / 2 / 2 ]
/ ( )[( / 2 ) / 2 ]
2 ( ) / 2 ( )
( ) 2 ( ) /
2 ( ) /
x x xa
f t t a b a
F x f t dt t a b a b a t at
b a x ax a a r
r h b a x ax a
b a r h x ax a x a
x a b a r h
x a b a r h
Find CDF CPG:
Show p(x) is a pdf:
=CDFubstituting h=2/(b-a):
=CPG
0 1r
0 1 for r
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
41/44
Distribution Diagram PDF CDF
Process
Generator
Uniform
Ramp - up
a b
f(x ) =
1
b - a a x b
0 Otherwise
F (x ) =
x - a
b - a
a x b
0 Otherwise
x = a + ( b - a ) r
0 r 1
a b
f (x ) =2 (x - a )( b - a )
a x b
0 Otherw ise
2 F(x ) =
( x - a )
( b - a ) a x b
0 Otherwise
2
2
Continuous Process Generators
10
)(2
r
h
abr a x
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
42/44
Continuous Process Generators
Ramp-Up
&Ramp -Down
a m b
f (x ) =
2 (x - a )
( b - a )( m - a ) a x m
2 ( b - x )
( b - a ) ( b - m ) m x b
0 Otherwise
f (x ) =
( x - a )
( b - a )( m - a ) a x m
( b - x )
( b - a ) ( b - m ) m x b
0 Otherwise
2
2
1
x = a+ r(b-a)( )
0 r ( ) / ( )
x = b - (1 -r)(b -a )( b m )
( ) / ( ) r 1
m a
m a b a
m a b a
Distribution Diagram PDF CDF ProcessGenerator
A
A=1/2base*height=(m-a)*(2/b-a)/2= (m-a)/(b-a)
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
43/44
Continuous Process Generators
Ramp - Down
Exponential
Distribution Diagram PDF CDFProcess
Generator
a b
f (x ) =
2 (b - x )
(b - a ) a x b
0 Otherwise
2
F (x ) =
( b - x )
(b - a ) a x b
0 Otherwise
2
21
x = b - (b - a)
r 1
2 ( )1
0
r
f (x ) = e x 0, 0
0 Otherwise
- x
F (x ) =
1 - e x 0
0 Otherwise
- x
x = -1
ln r
0 r 1
7/25/2019 3 - Simulation in Practice and Intro to Probability and Statistics
44/44
Questions?