You are on page 1of 12

INTRODUCTION

EG2080 Monte Carlo Methods • All observations in simple sampling are


in Engineering independent of each other.
Theme 4 • Sometimes it is possible to increase the
probability of a good selection of samples if
COMPLEMENTARY the samples are not independent.

RANDOM NUMBERS & Random


number
U Inverse
transform
Y Model
g(Y)
X Sampling
MX
generator method
DAGGER SAMPLING

1 2

MEAN OF TWO ESTIMATES MEAN OF TWO ESTIMATES


• Consider two estimates MX1 and MX2 of the • Expectation value:
same expectation value X, i.e.,
M X1 + M X2
EMX1EMX2X. E[MX] = E ---------------------------- =
2
• Study the mean of these estimates, i.e., 1 1
= ---  E  M X1  + E  M X2   = ---   X +  X  = X,(5)
M X1 + M X2 2 2
M X = ---------------------------- . i.e., the combined estimate MX is also an
2
estimate of X .

3 4
MEAN OF TWO ESTIMATES MEAN OF TWO ESTIMATES
• Variance: • If MX1 and MX2 both are independent
estimates obtained with simple sampling and
M X1 + M X2
Var[MX] = Var ---------------------------- = the number of samples is the same in both
2 simulations, then we get VarMX1VarMX2
1 1 and CovMX1 MX2. Hence, (6) yields
= --- Var  M X1  + --- Var  M X2  +
4 4 M X1 + M X2
1 Var[MX] = Var ---------------------------- =
+ ---  2Cov  M X1 M X2 . (6) 2
4
1 Var  M X1 
= ---  Var  M X1  + Var  M X1   = ------------------------- . (7)
4 2

5 6

MEAN OF TWO ESTIMATES COMPLEMENTARY RANDOM


• The variance obtained in (7) is equivalent to
NUMBERS
one run of simple sampling using 2n samples;
• A negative correlation between estimates can
according to theorem 11 we should get half
be created using complementary random
the variance when the number of samples is
numbers.
doubled.
• The complementary random number of a
• However, if the MX1 and MX2 are not
U(0, 1)-distributed random variable is
independent but negatively correlated then
U* = 1 – U.
the covariance term in (6) will make Var[MX]
- Correlation coefficient: U, U* = –1.
smaller than the corresponding variance for
simple sampling using the same number of
samples.

7 8
COMPLEMENTARY RANDOM COMPLEMENTARY RANDOM
NUMBERS NUMBERS
• If a random value is calculated using the • If a random value is calculated by analysing a
inverse transform method, i.e., Y= F Y– 1  U , scenario, i.e., X = g(Y), then the comple-
then the complementary random number is mentary random number is given by
given by Y* = F Y– 1  1 – U . X* = g(Y*).
- The complementary random number is calculated - Correlation coefficient: X, X*  Y, Y*.
in the same way also for normally distributed
random numbers generated according to the
approximative inverse transform method.
- For symmetrical distributions we get that if
Y = Y +  then Y* = Y – .
- Correlation coefficient: Y, Y*  U, U*.

9 10

ESTIMATES USING COMPLE- ESTIMATES USING COMPLE-


MENTARY RANDOM NUMBERS MENTARY RANDOM NUMBERS
• In practice, there is no need to differentiate
• Let MX1 be an estimate based on x1, …, xn.
between the origin of the samples; the final
• Let MX2 be an estimate based on the corre- estimate is simply
sponding complementary random numbers,
n
x1*, …, xn*. 1
• Obviously MX1 and MX2 are negatively corre- mX = ------   x i + x i * .
2n
lated. i=1

11 12
MULTIPLE INPUTS EXAMPLE 16 - Complementary
• Generally, the input vector Y has more than
random vector
one element. The input vector Y has the three elements A, B,
• The complementary random numbers of a C. The outcomes ai, bi, ci have been randomised
vector can be created by combining the for each element, and the corresponding
original and complementary random numbers complementary random numbers, ai*, bi*, ci*,
of each element in the vector. have been calculated.
It can be noted that each scenario yi will have Enumerate the original and complementary
more than one complementary scenario. scenarios if complementary random numbers
• It is possible to apply complementary random are applied to the following elements:
numbers only to a selection of the elements in
a) A, B, C.
Y.
b) A, B.

13 14

EXAMPLE 16 - Complementary EFFECTIVENESS


random vector • The variance reduction effect is depending on
Solution: a) Randomise three values, a, b, c and the correlation between xi = g(yi) and
calculate their complementary random xi* = g(yi*). This correlation depends on the
numbers. The results are combined as follows: correlation between Y and X.
[a, b, c], [a, b, c*], [a, b*, c], [a, b*, c*], • All inputs may not have a significant corre-
[a*, b, c], [a*, b, c*], [a*, b*, c], [a*, b*, c*]. lation to the outputs  no use in applying
complementary random numbers to these
b) Randomise six values, a, b, c1, c2, c3, c4 and inputs.
calculate the random numbers a* and b*. The
results are combined as follows: • Sometimes a stronger correlation can be
obtained by modifying the input probability
[a, b, c1], [a, b*, c2], [a*, b, c3], [a*, b*, c4]. distribution.

15 16
AUXILIARY INPUTS EXAMPLE 17 - Discrete auxiliary
• It might be possible to find a subset of the
input variable
inputs, Yi, i = 1, …, J such that there is a • In example 15, the net income is correlated to
strong correlation between YE = h(Y1, …, YJ) the demand.
(where h is an arbitrary function) and X. • The correlation between the demand for an
• When it can be worthwhile to introduce YE as individual flavour and the net income is not as
an auxiliary input variable to the system, and strong as the correlation between the total
apply complementary random numbers to YE demand and the net income.
instead of Yi, i = 1, …, J. • Hence, we can introduce the auxiliary input

Dtot =  Df .
fF

17 18

EXAMPLE 17 - Discrete auxiliary EXAMPLE 17 - Discrete auxiliary


input variables input variables
• We now have to find a joint probability distri- • The demand for each flavour can now be
bution for Dtot and Df, f = 1, …, 6. randomised with one value from the pseudo-
• The demand for each flavour has three random number generator, U.
possible states. The total number of combina- • The complementary demand for each flavour
tions is then 36 = 729. is calculated using U* = 1 – U.
• Enumerate all possible states, calculate the • The total demand based on U will be
probability for each state and sort the states negatively correlated to the total demand
according to increasing values of Dtot. based on U*.

19 20
EXAMPLE 18 - Normally EXAMPLE 18 - Normally
distributed auxiliary input distributed auxiliary input
• Gismo Inc. is selling their products to K • The probability distribution of Dtot is calcu-
retailers, and the demand of each retailer, Dk, lated using the addition theorems for normally
is N(k, k)-distributed. distributed random variables.
• The costs of Gismo Inc. has a stronger corre- • To generate the original scenario, randomise
lation to the total demand compared to the Dtot as well as temporary values of D1, …, DK.
demand of an individual retailer. Then scale the individual retailer demands to
• Introduce the auxiliary input variable match Dtot, i.e., let
Dtot = D1+ … + DK. D tot
Dk = ---------------- D k', where D k' is the
K
j D j' temporary value.

21 22

EXAMPLE 18 - Normally SIMULATION PROCEDURE


distributed auxiliary input - Complementary random numbers
U Y X
• To generate the complementary scenario, Random Inverse
Model MX
calculate the complementary random value of number transform
g(Y) Sampling
generator U* method Y* X*
Dtot and randomise new temporary values of
D1, …, DK. Then scale the individual retailer
demands to match Dtot*. • Step 1. Generate a random number uk, i and
calculate yi = F Yk – 1  u . If applicable to this
i k
scenario parameter, also calculate
– 1  1 – u .
yi* = F Yk i k
• Step 2. Repeat step 1 for all scenario
parameters. Create all complementary
scenarios and calculate xi = g(yi).

23 24
SIMULATION PROCEDURE SIMULATION PROCEDURE
- Complementary random numbers - Complementary random numbers
• Step 3. Repeat step 1 and 2 until enough • Step 5. Test stopping rule. If not fulfilled,
scenarios have been analysed for this batch. repeat step 1–4 for the next batch.
• Step 4. Update the sums • Step 6. Calculate estimates and present
n n results.

 x i and  x i2
i=1 i=1
or store all samples xi (depending on the
objective of the simulation).

25 26

EXAMPLE 19 - Effectiveness of EXAMPLE 19 - Effectiveness of


ICC simulation ICC simulation
Consider the same system as in example 15. Table 6 Results of ICC simulation in example 19.
Compare the true expectation values to the Expected net Risk for missed Average
probability distribution of estimates from a Simulation income [€/day] delivery [%] simulation
method time
complementary random number simulation Min Av. Max Min Av. Max [h:min:s]
using 200 samples.
Enumeration 874 0.32 0:34:54
Simple sam-
829 872 909 0.00 0.27 1.00 0:02:25
pling
Complemen-
tary ran-
842 875 914 0.00 0.27 1.00 0:02:25
dom
numbers

27 28
DAGGER SAMPLING DAGGER SAMPLING
• We have seen that a negative correlation • Consider a two-state input variable Y with the
between the outputs from different scenarios frequency function
can have a variance reducing effect.
• When the input is a two-state probability 1 – p x = A,
distribution, we can create a negative corre-

fY  x  =  p x = B, (8)
lation by using dagger sampling instead of 
complementary random numbers.  0 all other x,

where p.
• In dagger sampling, the inverse transform
method is replaced by a dagger transform
function.

29 30

DAGGER TRANSFORM DAGGER TRANSFORM


Definition 13: Assume that Y is • The dagger transform can be illustrated by
distributed according to (8) and let S be dividing an interval between 0 and 1 in S
the largest integer such that S  1/p.* sections, where each section has the width p.
Then, Yi, i = 1, …, S, is randomised • There will also be a remainder interval if
according to S·p < 1.
B if  i – 1 p  U  ip, U
F Yi  U  = 
A otherwise, p p p Remainder
where U is a random value from a • Each value of U generates S values of Y.
U(0, 1)-distribution. • yk = B if U is found in the k:th section, and all
* The value of S is referred to as the dagger cycle
length. other yi = A, i = 1, …, S, i k.

31 32
EXAMPLE 20 - Dagger transform EXAMPLE 20 - Dagger transform
The random variable Y is either equal to 2 (70% Solution: Here p = 0.3  S = 3. Moreover, we
probability) or 5 (30% probability). have A = 2 and B = 5.
a) Randomise three values of Y using dagger a)
sampling and the random value U = 0.34 from a
U(0, 1)-distribution. U
b) Randomise three values of Y using dagger 0 0.5 1
sampling and the random value U = 0.94 from a y1
U(0, 1)-distribution. y2
y3
y1=2
y2=5
y3=2

33 34

EXAMPLE 20 - Dagger transform CORRELATION OF DAGGER


Solution (cont.) SAMPLES
b) • The outputs X1, …, XS from the scenarios
generated in a dagger cycle will be negatively
correlated if the inputs Y1, …, YS are
U
negatively correlated (but the correlation
0 0.5 1 might be weaker).
y1
y2
• Are the input values Y i = F 
Yi  U , i = 1, …, S
y3 negatively correlated, i.e., what is the value
of
y1=2
y1=2 Cov[Yi, Yj] = E[YiYj] – E[Yi]E[Yj]?
y1=2

35 36
CORRELATION OF DAGGER CORRELATION OF DAGGER
SAMPLES SAMPLES
• There are two possible values for the product • Moreover, we have
YiYj: AB or AA. There are two sections there E[Yi] = E[Yj] = (1 – p)A + pB.
either Yi or Yj will be transformed to B; hence,
the probability for this event is 2p. Thus, we • The covariance can now be calculated as
get Cov[Yi, Yj] = E[YiYj] – E[Yi]E[Yj] =
E[YiYj] = 2pAB + (1 – 2p)AA. = 2pAB + (1 – 2p)AA – ((1 – p)A + pB)2 =
y1 = … = = –p2(A + B)2 < 0.
y2 • The input values are negatively correlated and
y3 we can therefore expect a negative corre-
lation in the outputs too.

37 38

MULTIPLE INPUTS MULTIPLE INPUTS


Assume that a computer simulation has several • Alternative 2: Reset all dagger cycles at the
two-state input variables. Which dagger cycle end of the longest cycle.
length should be chosen? Scenarios
• Alternative 1: Independent dagger cycles. Inputs
Scenarios
Inputs

39 40
MULTIPLE INPUTS SIMULATION PROCEDURE
- Dagger sampling
• Alternative 3: Reset all dagger cycles at the
Y X
end of the shortest cycle. Random
U Dagger Model MX
Scenarier number
transform g(Y) Sampling
generator YS XS
Inputs

• Step 1. Generate a random number uk, i and


calculate yi = F 
Yi  u i k  for one dagger cycle.
• Step 2. Repeat step 1 for all scenario
parameters. Combine the dagger cycles and
calculate xi = g(yi).

41 42

SIMULATION PROCEDURE SIMULATION PROCEDURE


- Dagger sampling - Dagger sampling
• Step 3. Repeat step 1 and 2 until enough • Step 5. Test stopping rule. If not fulfilled,
scenarios have been analysed for this batch. repeat step 1–4 for the next batch.
• Step 4. Update the sums • Step 6. Calculate estimates and present
n n results.

 x i and  x i2
i=1 i=1
or store all samples xi (depending on the
objective of the simulation).

43 44
EXAMPLE 21 - Effectiveness of EXAMPLE 21 - Effectiveness of
ICC simulation ICC simulation
Consider the same system as in example 15. Table 7 Results of ICC simulation in example 21.
Compare the true expectation values to the Expected net Risk for missed Average
probability distribution of estimates from a Simulation income [€/day] delivery [%] simulation
method time
dagger sampling simulation using 200 samples. Min Av. Max Min Av. Max [h:min:s]

Enumeration 874 0.32 0:34:54


Simple samp. 829 872 909 0.00 0.27 1.00 0:02:25
Compl. r.n. 842 875 914 0.00 0.27 1.00 0:02:25
Dagger sam-
856 877 900 0.00 0.27 1.00 0:02:27
pling

45 46

VARIANCE REDUCTION
• To achieve a variance reduction, we need to
have some information of the simulated
system.
• For complementary random numbers, we
need to identify the inputs where a negative
correlation between scenarios will result in
negative correlations for one or more outputs.
• For dagger sampling, we need to identify two-
state inputs where a negative correlation
between the scenarios will result in negative
correlations for one or more outputs.

47

You might also like