Академический Документы
Профессиональный Документы
Культура Документы
147
148
150
151
152
153
BACKGROUND
154
MARKOV-PROCESS PRIMER
A continuous-time Markov process is a stochastic process {Yt; t 0}
with state-space a subset of {0, 1, 2, . . .}.
Examples include queueing, reliability, inventory, combat, biological
processes.
Characteristics:
Time spent in each state is exponentially distributed.
Next state entered depends only on the current state.
MPs can be analyzed via mathematical analysis, but when the state
space is large numerical analysis or simulation may be required.
155
For i 6= j, 1/gij is the mean of the exponential time until the process
moves from state i to j.
gij can be interpreted as the transition rate from i to j.
For i = j, 1/gii = 1/
time in state i.
P
j6=i gij is the mean of the exponential holding
156
TTF EXAMPLE
State space {0, 1, 2} corresponds to number of functional computers.
B is the time until computer breakdown, exponentially distributed
with mean 1/, or failure rate .
R is the time to repair a computer, exponentially distributed with
mean 1/, or repair rate .
Generator for {Yt; t 0} is
= ( + )
157
STATE-CHANGE PROCESS
Let {Xn; n = 0, 1, 2, . . .} be the state-change process, where n counts
the number of state changes without regard to time.
The probability of transition from i to j is pij = gij /gii, and from i
to i is pii = 0, provided gii > 0. If gii = 0 then pii = 1.
Transition matrix for TTF example is
= /( + ) 0 /( + )
= 1/1001
1000/1001
1
0
158
CRUDE EXPERIMENT
Variance is reduced relative to a crude experiment.
Example: Estimate = E[Y ] (expected TTF)
] = 2 /n where
If Y1, . . . , Yn are i.i.d. then Var[Y
Y
Y2 = Var[Y ] = E[(Y )2 ]
VRTs try to do better than this.
number of independent replications: n
point estimator: Y
160
161
ANTITHETIC VARIATES
AV applies to estimating an absolute parameter.
The idea is to balance bad system performance with good system
performance to obtain a better estimate of mean performance.
This is accomplished by balancing the pseudorandom numbers across
replications.
Rather than balance across all n replications, we typically balance
across pairs of replications.
We hope to end up with negatively correlated (antithetic) pairs of
outputs.
162
1 X
=
j
Y
Y
n/2 j=1
Y2
] =
(1 + )
Var[Y
n
where = Corr[Y2j1, Y2j ].
163
AV EXPERIMENT
number of independent replications: n/2
point estimator Y
q
t1/2,n/21S
2/n
interval estimator: Y
where
n/2
2
X
1
2
=
j Y
S
Y
n/2 1 j=1
164
IMPLEMENTATION
In replications 2i 1 and 2i we want U and 1 U to be used for the
same purpose. Assigning a distinct stream to each input process
helps.
The random variate generators in many simulation languages have
calling sequences like
NORMAL(mean, stddev, stream)
Supposedly if you use -stream you obtain the antithetic variates.
However, if the generator is not inverse cdf then there may be no
antithetic effect.
165
CODE FOR AV
To keep the random numbers sychronized, we run the pairs together
until the last one quits.
Public Sub TTFAV(Lambda As Double, Mu As Double, _
Sum As Double, AVSum As Double)
sub to generate one pair of antithetic replications of the ttf for the
airline reservation system
variables
166
167
antithetic run
If AVState > 0 Then
Fail = -VBA.Log(U1) / Lambda
Repair = -VBA.Log(U2) / Mu
If AVState = 2 Then
AVSum = AVSum + Fail
AVState = 1
Else
If Repair < Fail Then
AVSum = AVSum + Repair
AVState = 2
Else
AVSum = AVSum + Fail
AVState = 0
End If
End If
End If
Wend
End Sub
168
EFFECTIVENESS OF AV
] < Var[Y
]
If < 0 then Var[Y
If < (, n) then
q
169
1
2
1
2/10
1/20
5/20
2
1/10
8/20
10/20
3
1/10
3/20
5/20
4/10
12/20
Then
E[T ] = (1)5/20 + (2)10/20 + (3)5/20 = 2
The conditional distribution of T given S is
T
a
Pr{T = a|S = 1}
Pr{T = a|S = 2}
1
2/4
1/12
2
1/4
8/12
3
1/4
3/12
1.00
1.00
170
Therefore,
E[T |S = 1] = (1)2/4 + (2)1/4 + (3)1/4 = 7/4
E[T |S = 2] = (1)1/12 + (2)8/12 + (3)3/12
= 26/12
E[T ] = ES ET |S [T |S]
In our case
h
ES ET |S [T |S]
= E[T |S = 1] Pr{S = 1}
+ E[T |S = 2] Pr{S = 2}
= (7/4)(4/10)
+ (26/12)(12/20) = 2
For variance reduction, these results imply that we can use E[T |S]
to estimate E[T ].
CONTROL VARIATES
In CV we approximate E[Y |C] as
E[Y |C] 0 + 1(C C )
(1)
171
b1(C
C )
b0 = Y
where
Pn
)(Ci C)
(Yi Y
i=1
b
1 =
.
Pn
2
(C
C)
i
i=1
?
How does b0 compare to Y
172
P
P
)|C = c](ci
E[(Yi Y
c)
P
(ci
c)2
(0 + 1(ci C ) 0 1(
c C ))(ci
c)
P
(ci
c)2
= 1 .
=
173
Notice that
h
i
h
i
b
b
b
Var[0] = Var E[0|C] + E Var[0|C]
h
i
= E Var[b0|C]
h
i
since Var E[b0|C] = Var[0] = 0 from the proof of the result above.
C )2
1
(
C
2
+P
.
Var[b0|C] =
2
n
(Ci C)
174
C )2
(C
1
E P
.
=
2
(Ci C)
n(n 3)
Result: If (Y, C) are bivariate normal, then
Y2
n2
2
b
Var[0] =
(1 ) .
n3
n
Thus, if 2 > 1/(n2) then the control-variate estimator has smaller
variance than the sample mean.
175
The sce and confidence interval for are the usual ones for the
intercept term of a least-squares regression.
Regression set up:
Y1
Y2
..
Yn
1 C1 C "
1 C2 C
..
1 Cn C
0
1
+ = C +
b = (C0C)1 C0Y
b0 t1/2,n2sce
b ] = (Y 0Y 0C0Y )(C0 C)1/(n 2)
d
Var[
176
CV for TTF
Possible control variates:
We know the distribution of the time until a computer breakdown.
C1 = average time until a computer breakdown (E[C1 ] = 1/)
The number of times the process enters state 1 has a geometric
distribution with parameter
/( + )
C2 = number of times process is in state 1
(E[C2 ] = ( + )/)
177
CODE FOR CV
Public Sub TTFCV(Lambda As Double, Mu As Double, Sum As Double, _
CV1 As Double, CV2 As Double)
sub to generate one replication of the ttf for the
airline reservation system and record two control variates
variables
State As Integer
Fail As Double
Repair As Double
Sum1 As Double
Count1 As Double
State = 2
Sum = 0
Sum1 = 0
Count1 = 0
Count2 = 0
178
Y1
Y2
..
Yn
1 C11 C1 C1q Cq
0
1 C21 C C2q C
1
q
1
+
=
..
..
q
1 Cn1 C1 Cnq Cq
Var b0 =
n2
2
]
(1 RY
)Var[Y
C
nq2
CONDITIONAL EXPECTATIONS
CE is useful when E[Y |X] is known for all X, because
E [E[Y |X]] =
and
Var [E[Y |X]] = Var[Y ] E [Var[Y |X]]
181
CE EXPERIMENT
number of independent replications: n
ce
point estimator Y
182
CE for TTF
We can write
TTF = H1 + H2 + + HN
where Hn is the holding time in the nth state entered, and N is the
number of states entered before system failure.
But
E[Hn|Xn = 2] = 1/
E[Hn|Xn = 1] = 1/( + )
Thus we condition on X = (X1 , . . . , XN )
Yce = E[H1|X1 ] + E[H2|X2, X1 ] +
+ E[HN |XN , . . . , X1 ]
= E[H1|X1 ] + E[H2|X2] + + E[HN |XN ]
183
CODE FOR CE
Public Sub TTFCE(Lambda As Double, Mu As Double, Sum As Double)
sub to generate one replication of the ttf for the
airline reservation system using conditional expectations
variables
End If
End If
Wend
End Sub
IMPORTANCE SAMPLING
Suppose we represent
=
Z
A
g(z)f (z) dz
f (z ) 0
=
f (z) dz
g(z) 0
f (z )
A
This is now an expectation with respect to f 0.
If g(z)f (z)/f 0 (z) is nearly constant for all z, then we have reduced
variance.
In fact, if f 0 = gf / then the variance is 0!
185
The random variable f (Z)/f 0 (Z) is called the likelihood ratio (LR).
Frequently, Z = (Z1 , Z2, . . . , ZN ) are independent so that
QN
f (Z )
i=1 f (Zi )
LR = 0
= QN
0
f (Z )
i=1 f (Zi)
186
IS for TTF
If we change the failure rate to 0 and the repair rate to 0 then
the LR for Yt is
QN B
Bi QNR eRj
e
i=1
j=1
LR = QN
B 0 e0 Bi QNR 0 e0 Rj
i=1
j=1
PNR
j=1 Rj
NB e i=1 Bi NR e
P NB
PNR
0
0
(0)NB e i=1 Bi (0)NR e i=1 Ri
PNB
187
CODE FOR IS
Public Sub TTFIS(Lambda As Double, Mu As Double, _
LambdaPrime As Double, MuPrime As Double, _
Sum As Double, LikelihoodRatio As Double)
sub to generate one replication of the ttf for the
airline reservation system using importance sampling
variables
188
189
State As Integer
Fail As Double
Repair As Double
HoldingTime1 As Double
HoldingTime2 As Double
190
191
192
VRT EXERCISE
Problem: Estimate p = Pr{Y > a} and E[Y ] where
Y = max{X1 + X4 + X6 , X1 + X3 + X5 + X6 , X2 + X5 + X6}
Crude Experiment:
1. sum 0
2. repeat n times:
sample X1 , . . . , X5
Y = max{X1 + X4 + X6 , X1 + X3 + X5 + X6, X2 + X5 + X6 }
sumP = sumP +I(Y > a)
sumM = sumM +Y
3. return p = sumP/n
= sumM/n
Y
193
DETAILS
Let the Xi be i.i.d. exponential(1).
Take a = 6, n = 30.
Try every variance reduction technique we learned on one of the two
problems (or both).
You must demonstrate that at least one of your VRTs works on each
problem. Use the experiment-within-an-experiment approach with
m macroreplications and form a confidence interval on the variance
ratio.
Remember that the practitioner gets only one experiment, but the
researcher gets as many as necessary to establish properties.
194