Professional Documents
Culture Documents
L.E. Meester
Week 5
1/ 44
Understanding bias Control variates Importance sampling
3/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
>> DeltaCall2B2
M = 1000
h = 1
Delta = 0.9398
seDelta = 0.0093
h = 0.5000
Delta = 0.9208
seDelta = 0.0105
5/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
B. Another run:
>> DeltaCall2B2
M = 100000
h = 1
Delta = 0.9300
seDelta = 0.0010
h = 0.5000
Delta = 0.9094
seDelta = 0.0011
6/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
7/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
∆ˆ (0.1) = ∆0 + bias(0.1) + 1
ˆ (0.01) = ∆0 + bias(0.01) + 2
∆
ˆ (0.1) − ∆
∆ ˆ (0.01) = bias(0.1) − bias(0.01) + 1 − 2 .
Note: We know none of the terms on the right, only their sum. . .
However: the s.e.’s provide an indication of the “size” of 1 and 2 .
If the standard errors are
ˆ (0.1) − ∆
small: then the sum ∆ ˆ (0.01) ≈ bias(0.1) − bias(0.01)
and we “see” how big the reduction in bias is;
big: the random errors dominate, the reduction in bias is
smaller; nothing more can be said.
9/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
10/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
In practice:
1 is all the information you have, this is all you know;
2 you should try to imagine/visualise; you know it’s there, your
results are just “one set from the histograms.”
11/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
12/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
13/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
14/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
15/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
16/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
17/ 44
Understanding bias Control variates Importance sampling Bias detection: analysis Envisioning what you can’t really see
>> DeltaCall2B2
M = 100000
h = 1
Delta = 0.9300
seDelta = 0.0010
h = 0.5000
Delta = 0.9094
seDelta = 0.0011
19/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
20/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
ˆ 2 ≈ 2 Var(W ) · [1 − ρ (Wh , W )]
Var ∆
h2 M
Analysing antithetic variables:
21/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
22/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
E [Z ] = E [X ] + E [Y ] − E [Y ] = I ;
24/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
A simple example
25/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
Some plots
√
Left: X and Y versus U (in fact plots u 7→ eu and e u ).
Right: Simulated pairs (X , Y ). They have a strong correlation.
26/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
27/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
Zθ = X + θ · (E [Y ] − Y )
Cov(X , Y ) 2
h i
Var(Zθ ) = Var(X )· 1 − ρ (X , Y )2 +Var(Y )· θ − .
Var(Y )
28/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
Implementation
In practice:
Cov(X , Y ) is not known (why?); often neither is Var(Y ).
Solution: estimate them from the simulation.
The simulation then looks like this:
1 Compute µY = E [Y ].
2 Generate pairs (X1 , Y1 ), . . . , (XM , YM ). (Save them)
3 Compute the sample covariance of X and Y and the sample
variance of Y , and estimate θmin = Cov(X , Y ) /Var(Y ).
4 Now determine for i = 1, . . . , M: Zi = Xi + θ̂min · (µY − Yi ).
5 Process Z1 , . . . , ZM in the usual way.
Matlab: HigS222b-c.m
29/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
30/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
31/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
32/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
33/ 44
Understanding bias Control variates Importance sampling Correlation=key Idea Example Refinement A classic examp
Zθ = X + θ · (µY − Y ).
Cov(X , Y ) σX
The best θ is: θmin = ≡ ρ (X , Y ) .
Var(Y ) σY
This leads to a reduction factor 1 − ρ2 :
h i
Var(Zθmin ) = Var(X ) · 1 − ρ (X , Y )2 .
34/ 44
Understanding bias Control variates Importance sampling The principle Example
35/ 44
Understanding bias Control variates Importance sampling The principle Example
R1
For a function k : [0, 1] → R one can determine I = 0 k(x)dx
by Monte Carlo, using that I = E [k(U)], with U ∼ U (0, 1).
Let’s make explicit that there is a density term: write
Z 1
I = k(x)f (x)dx,
0
36/ 44
Understanding bias Control variates Importance sampling The principle Example
Z 1
f (x)
I = k(x) g (x) dx.
0 g (x)
37/ 44
Understanding bias Control variates Importance sampling The principle Example
The ratios
f (x) f (X )
w (x) = and w (X ) =
g (x) g (X )
38/ 44
Understanding bias Control variates Importance sampling The principle Example
f (x)
w (x) = and I = E [k(X )w (X )] , with X ∼ g .
g (x)
k(x)f (x)
k(x)w (x) = ≈ constant,
g (x)
39/ 44
Understanding bias Control variates Importance sampling The principle Example
40/ 44
Understanding bias Control variates Importance sampling The principle Example
41/ 44
Understanding bias Control variates Importance sampling The principle Example
Example: determining π
√
To estimate π we used Y = 4 1 − U 2 with U ∼ U (0, 1).
R1 √
Then E [Y ] = 0 4 1 − x 2 dx = π and
from earlier simulation: Var(Y ) ≈ 0.797.
Here:
√
k(x) = 4 1 − x 2 and
f (x) = 1 for 0 ≤ x ≤ 1, f (x) = 0 elsewhere.
So, by the theory just developed, we look for g
positive on [0, 1];
√
proportional to 1 − x 2 .
42/ 44
Understanding bias Control variates Importance sampling The principle Example
We look for g
positive on [0, 1];
√
proportional to 1 − x 2 .
Note: √
1 − x 2 decreases from 1 to 0 on [0, 1].
Let’s try a decreasing density g (x) for 0 ≤ x ≤ 1:
1 Perhaps g (x) ∝ 1 − x 2 ? (Details on board.)
Results in G (x) = 12 (3x − x 3 ), 0 ≤ x ≤ 1.
Fails, because we cannot solve G (x) = u.
2 Try g2 (x) ∝ 2 − x. (Details on board.)
Results in G2 (x) = 43 x − 31 x 2 , 0 ≤ x ≤ 1.
√
Simulate X ∼ G2 by X = 2 − 4 − 3U.
Details/Matlab: SchatPi_IS2.m
Gain: about a factor 4.
43/ 44
Understanding bias Control variates Importance sampling The principle Example
44/ 44