Professional Documents
Culture Documents
2 Options
Exercise 2.1. Prove that
r(T t)
St K CA PA S t Ke
RMSC 4001 Since 8
> r(T t)
Simulation Methods for Risk Management Science <PE + St = CE + Ke
CE = CA
>
:
and Finance PA PE
r(T t) r(T t)
Tutorial 1 Solution: Options and Futures PA CA + Ke St ) CA PA S t Ke
Consider two portfolios:
Chen Kexin⇤ A: one European call option and K money account
B: one American put and one unit of stock
Department of Statistics, The Chinese University of Hong Kong
Case I: The American put is exercised at maturity T
AT = max(ST K, 0) + Ker(T t)
= max(ST , K) + K[er⇤(T t)
1]
1 Forward and Futures
BT = max(K ST , 0) + ST = max(ST , K) AT
Exercise 1.1. A stock is expected to pay a dividend of $1 per share in two months and in five months.
Case II: The American put is exercised at ⌧ 2 [t, T )
The stock price is $50, and the risk-free rate of interest is 8% per annum with continuous compounding
for all maturities. An investor has just taken a short position in a six-month forward contract on the
stock. AT Ker(T t)
a) What are the forward price and the initial value of the forward contract? r(T ⌧) r(T ⌧)
BT = (K S⌧ + S⌧ )e = Ke Ker(T t)
AT
b) Three months later, the price of the stock is $48 and the risk-free rate of interest is still 8% per
annum. What are the forward price and the value of the short position in the forward contract?
Therefore
(a) CE + K = CA + K PA + S t ) CA PA St K
f0 = 0
0.08⇤2/12 0.08⇤5/12
I=e +e = 1.954
F0 = (50 1.954)e0.08⇤1/2 = 50.01
(b)
0.08⇤2/12
I=e = 0.9868
F1/4 = (48 0.9868)e0.08⇤3/12 = 47.96
0.08⇤3/12
f1/4 = (48 0.9868 50.01 ⇤ e ) = 2.01
Exercise 1.2. Suppose that F1 and F2 are two futures prices on the same commodity where the times to
maturity of the contracts are t1 and t2 with t2 > t1 . Prove that F2 F1 er(t2 t1 ) , where r is the interest
rate (assumed constant) and there are no storage costs. For the purposes of this problem, assume that
a futures contract is the same as a forward contract.
If F2 > F1 er(t2 t1 ) ,consider the following strategy:
Take long position of future mature at t1 and short position of future mature at t2
At t1 , buy the commodity with F1 which is borrowed at r,
At t2 , sell the commodity with F2 and pay the debt with F1 er(t2 t1 )
Risk-free profit at t2 = F2 F1 er(t2 t1 ) > 0
⇤ kxchen@link.cuhk.edu.hk
1 2
2 ITO’S PROCESS AND ITO’S LEMMA
⇤ s1155029151@link.cuhk.edu.hk
1 2
Exercise 0.2. .
1
RT
Suppose Y = T 0
lnSt dt and (
dSt = rSt dt + St dWt
RMSC 4001 S0 = s
and Finance 1
Z T
Y = ln(St ) ln(S0 ) + ln(S0 )dt
T 0
Tutorial 4 Solution: Black-Scholes Model and Ito’s integral Z T
1 St
= ln( )dt + ln(S0 )
T 0 S0
Chen Kexin⇤ Z
1 T 1 2
= ln(S0 ) + (r )t + Wt dt
T 0 2
Department of Statistics, The Chinese University of Hong Kong 1 2
where we have used St = S0 e(r 2 )t+ Wt
Z Z
1 T 1 2 1 T
Exercise 0.1. Suppose the price of contingent claim satisfies the PDE = ln(S0 ) + (r )tdt + Wt dt
T 0 2 T 0
( 2 Z T
@f @f 1 2 2@ f 1 1 1
@t + rS @S + 2 S @S 2 rf = 0 = ln(S0 ) + (r )T + Wt dt
2 2 T 0
f (S, T ) = max(S K, 0)
1
RT
Show that Now we check the expectation and variance of T 0
Wt dt. First we apply Ito’s lemma to tWt .
rT (This guessed by integration by part). In fact,
f (S, 0) = e E[max(ST K, 0)]
Where ST is the solution to the SDE: dtWt = Wt dt + tdWt
(
dSt = rSt dt + St dWt Therefore, by taking integral on both sides:
S0 = s Z T Z T
T WT 0= Wt dt + tdWt
0 0
@f @f 1 2 2@ f 2
@f RT RT
df (S, t) = (
+ rS + S )dt + S dWt We conclude that 0
Wt dt = T WT 0
tdWt .
@t @S 2 @S 2 @S
@f Z T
= rf dt + S dWt 1
@S E[ Wt dt] = 0
T 0
rt rt @f Z T Z T Z T
e (df rf dt) = e S dWt 1 2 t 2 t
@S V ar[ Wt dt] = V ar[WT dWt ] = V ar[ (1 )dWt ]
T T T
rt rt @f Z
0 0 0
d(e f ) = e S dWt T 2
@S t 2 T
Z T = 2 (1 ) dt = .
rT rt @f 0 T 3
e f (S, T ) f (S, 0) = e S dWt
0 @S
Y is normally distributed with
rT rT
f (S, 0) = e E[f (S, T )] = e E[max(ST K, 0)] ✓ ◆
1 1 2
E(Y ) = lns + r T
2 2
Z T ✓ ◆2 2
2 t T
V ar(Y ) = 1 dt =
0 T 3
⇤ s1155029151@link.cuhk.edu.hk
1 2
2 MONTE CARLO SIMULATION
and Finance • ✓: the interested parameter related to X in the form E(h(X)), e.g. E(X), E(X 2 ).
Objective: Estimate ✓
⇤†
Kexin CHEN Algorithm:
• Step 1: Generate Xi
Theorem 1.1 (# Weak Law of Large Number). Let X1 , X2 , . . . are independent identically distributed When n is large enough, ✓ˆ is a good estimator because it is unbiased and consistent by Week Law
(i.i.d.) random variables with of Large Number.
x P (|Xi | > x) ! 0 as x ! 1
Exercise 2.1. Suppose a stock follows the dynamics
Let Sn = X1 + · · · + Xn and µn = E(X1 1(|X1 |<n) ), then
dSt = rSt dt + St dWt
Sn /n µn ! 0 in probability as n ! 1
The risk-neutral pricing formula of European call option is
Theorem 1.2 (# Strong Law of Large Number). Let X1 , X2 , . . . are pairwise independent identically rT
C0 = e E[max(ST K, 0)]
distributed random variables with
E|Xi | < 1 Suppose r = 0.05, = 0.3, S0 = 50, K = 52, write down the algorithm and VBA programme to
Let Sn = X1 + · · · + Xn and EXi = µ, then approximate the half-year call option price by 10000 simulation paths.
Sub calloption()
Dim r, sigma, S0, ST, K, T, payoff, price, z As Variant
Randomize
r = 0.05
sigma = 0.3
S0 = 50
K = 52
T = 0.5
price = 0
For i = 1 To 10000
z = Application.NormSInv(Rnd())
ST = S0 * Exp((r - 0.5 * sigma ˆ 2) * T + sigma * Sqr(T) * z)
payoff = Application.Max(ST - K, 0)
price = price + payoff / 10000
Next i
Cells(1, 1).Value = Exp(-r * T) * price
End Sub
⇤ kxchen@link.cuhk.edu.hk, Department of Statistics, The Chinese University of Hong Kong
† Material is based on the previous version by Zhiling GU
1 2
3 INVERSE TRANSFORM 3 INVERSE TRANSFORM
As shown in Monte Carlo simulation algorithm, we need to simulate the random variable related to our Exercise 3.1. The PMF of the geometric random variable X is :
interested parameters. If we know the distribution of the random variables, we can simulate them using
multiple algorithms. Here we first introduce inverse transform. P(X = j) = p(1 p)j 1
j = 1, 2, ...
Notations: 1 (1 p)j
FX (j) = p =1 (1 p)j
1 (1 p)
• fX (x) : X 7! [0, 1) is the probability density function (PDF) or probability mass function
(PMF) of random variable X Algorithm:
• FX (x) : X 7! [0, 1] is the cumulative density function (CDF) or cumulative mass function • Step 1: Generate a random number U ⇠ Uniform(0, 1)
(CMF) of random variable X
• Step 2: Set X = j if U 2 [FX (j 1), FX (j))
• X : the domain of random variable X
Objective: Simulate X ⇠ FX To be specific,
X=j if 1 (1 p)j 1
U <1 (1 p)j
Algorithm (Discrete case): Generate a discrete random variable X with PMF: ln(1 U) ln(1 U)
<j +1
X ln(1 p) ln(1 p)
P(X = xj ) = pj j = 0, 1, ..., pj = 1
ln(1 U)
j X=b c+1
ln(1 p)
• Step 1: Generate a random number U ⇠ Uniform(0, 1). where buc = the maximum integer less or equal to u, called the floor of a number
• Step 2: Transform U into X as follows,
Log(): natural log
j 1
X j
X Int(): floor, rounds a real number down to an interger
X = xj if pi U < pi
i=0 i=0
Sub geometric()
This algorithm works because Dim u, x, p As Variant
p = 0.25
j 1 j j j 1 Randomize
X X X X For i = 1 To 10000
P(X = xj ) = P( pi U < pi ) = pi p i = pj u = Rnd()
i=0 i=0 i=0 i=0 x = Int(Log(1 - u) / Log(1 - p)) + 1
Cells(i, 1).Value = x
Next i
End Sub
Remark 3.1. To generate U ⇠ Uniform(0, 1) in VBA, following code generate a random number from
[0, 1) uniformly.
U = Rnd()
Remark 3.2. The algorithm above can be summarize as: if xj are ordered so that x0 < x1 < ... and F
denotes the distribution of X, then
That is after generating U , we determine the value of X by finding the interval [F (xj 1 ), F (xj )) in
which U lies. This also means that we want to find the inverse of F (U ) and thus the name of inverse
transform.
3 4
3 INVERSE TRANSFORM
5 1
1 ACCEPTANCE-REJECTION METHOD 1 ACCEPTANCE-REJECTION METHOD
Theorem 1.1. The random variable X generated by rejection method has density f . Moreover, Program Hints
the number of iterations that this algorithm needs is geometric random variable with mean c. ‘Do-While’ Loop: Do... Loop While...
Assign value to a vector: Dim v() As Variant; v = [{1,2,3,4,5,7}]
Proof Change the length of a vector: ReDim v(1 to 7)
Let A be acceptance event, consider ‘Floor’ function: Int(), i.e. round down to the nearest integer
Z 1
P(A, Y x) = P(A, Y x|Y = y)g(y)dy Solution
1
Z x
Let Y be a discrete uniform random variable with P(Y = k) = 1
7 for k = 1, . . . , 7. Observe that
= P(A|Y = y)g(y)dy
1 P(X = k)
Z x ✓ ◆ c = max = max 7 · P(X = k) = 7 · P(X = 1) = 2.1.
f (Y ) k P(Y = k) k
= P U Y = y g(y)dy
1 cg(Y )
Z x ✓ ◆ Therefore, we set c = 2.1. Here is the algorithm:
f (y)
= P U g(y)dy 1. Generate Y from the discrete uniform distribution.
1 cg(y)
Z
1 x 2. Generate U from Uniform(0, 1).
= f (y)dy
c 1
P(X = y) P(X = y)
3. If U = , set Xi = Y . Otherwise, return to step 1.
Note that the last equality holds only when f (y)
1. c · P(Y = y) 0.3
cg(y)
4. Repeat Step 1 to 3 for 1, 000 times.
By passing x ! 1,
1
P(A) = Function rejection_discrete3()
c
Dim p() As Variant
Therefore, Z ’Assign a vector to p
x
P(A, Y x) p = [{0.3,0.12,0.09,0.12,0.1,0.17,0.1}]
P(X x) = P(Y x | A) = = f (y)dy
P(A) 1 Do
’Step 1: Inverse transform to simulate dicrete uniform
u1 = Rnd()
Exercise 1.1. Use acceptance-rejection method to simulate 1000 samples from the following discrete
y = Int(7 * u1 + 1)
distribution. What is the theoretical acceptance rate? Confirm it by reporting the number of trials until
1000 samples are generated. ’Step 2:
u2 = Rnd()
x 1 2 3 4 5 6 7
rejection_discrete3 = y
P (X = x) 0.3 0.12 0.09 0.12 0.1 0.17 0.1 ’Step 3:
Loop Until u2 < p(y) / 0.3
End Function
Sub run_discrete()
N = 1000
’temp: store the number of trials
temp = 0
For I = 1 To N
’store accepted simulation in vector x
x(I) = rejection_discrete3()
Next I
For j = 1 To N
Cells(j, 1).Value = x(j)
Next j
Cells(1, 2).Value = temp
End Sub
2 3
2 GENERATING NORMAL RANDOM VARIABLES 2 GENERATING NORMAL RANDOM VARIABLES
Exercise 1.2. Suppose we want to simulate 10000 samples from the density Generate correlated normal random variable
3
Objective: Generate two standard normal random variables X1 and X2 with correlation ⇢.
f (x) = 20x(1 x) 0<x<1 Algorithm:
Provide an acceptance-rejection algorithm to simulate X ⇠ F • Step 1: Generate Z1 and Z2 with i.i.d N (0, 1)
f (x) 135 • Step 2: Transform Z1 and Z2 to X1 and X2 by
c = max =
x g(x) 64 (
X1 = Z 1
1. Generate U1 ⇠ Uniform(0, 1). p
X2 = ⇢Z1 + 1 ⇢2 Z 2
2. Generate U2 ⇠ Uniform(0, 1).
64
3. If U2 135 20U1 (1 U1 )3 , set X = U1 . Otherwise return step 1. Exercise 2.1. Consider two stocks, A and B and let Sa (t) and Sb (t) be the price of them at time t
where the dynamics are
4. Repeat Step 1 to 3 for 10,000 times.
dSa (t) = rSa (t)dt + a Sa (t)dW1 (t)
Function rejection_continuous() dSb (t) = rSb (t)dt + b Sb (t)dW2 (t)
Dim u1, u2 As Variant
Randomize Corr(W1 , W2 ) = ⇢
End Sub
are two independent standard normal random variables. The following VBA function outputs
standard normal by this method.
Public Function rGauss()
Dim X1 As Variant, X2 As Variant, r As Variant
100
X1=2*Rnd()-1
X2=2*Rnd()-1
r=X1ˆ2+X2ˆ2
End Function
4 5
2 GENERATING NORMAL RANDOM VARIABLES
z2 = Application.NormSInv(Rnd()) dt de rt d der(T t )
rt⇤ t⇤ )
X1 = z1 C E + Kt + dt CE (0) + Ke rT + de / (ST _ K) + der(T
t⇤ )
X2 = p * z1 + Sqr(1 - p ˆ 2) * z2 PE + S t PE (0) + S0 / (ST _ K) + der(T
S1T = S1 * Exp((r - 0.5 * sigma1 ˆ 2) * T + sigma1 * Sqr(T) * X1)
S2T = S2 * Exp((r - 0.5 * sigma2 ˆ 2) * T + sigma2 * Sqr(T) * X2) By put-call parity, a non-arbitrage put option should worth:
If n1 * S1T + n2 * S2T <= 0.9 * (n1 * S1 + n2 * S2) Then
rT rt⇤ 0.1⇤3/12 0.1⇤1/12
I = 1 PE = CE + Ke + de S0 = 3 + 20e +e 19 = 4.5
Else ’ElseIf n1 * S1T + n2 * S2T > 0.9 * (n1 * S1 + n2 * S2) Then
I = 0 Therefore, the put option is cheaper than its non-arbitrage price.
End If Consider a portfolio: long one put, long one stock and short one call.
theta = theta + I / N - Initial cost = 19.
Next j - At maturity, either the put or the call will be exercised. The payo↵ is 20 + e0.1⇤2/12 if ST < 20,
Cells(1, 1).Value = theta or ST + (ST 20) + e0.1⇤2/12 if ST > 20.
End Sub The present value of gain is at least
0.1⇤3/12 0.1⇤1/12
19 + 20e +e = 1.5
⇤ s1155061903@link.cuhk.edu.hk
† Material is based on the previous version by Zhiling GU
6 1
1 EXERCISES 1 EXERCISES
Since the last two portfolios in the table above are the same at maturity, they must have the same (a)
value at initial time, i.e. 1 t
CE + Ke rT = S0 e qT + PE . dyt = ✓et e 2
dt + et dWt .
2
⇤ (b)
1 2
T ✓ 2 T
Exercise 1.3. (Random number generation) E(ln ST ) = e lnS0 + (1 e ),
Suppose we want to simulate |Z|, where Z ⇠ N (0, 1). The p.d.f of |Z| is given by 2
V ar(ln ST ) = (1 e 2T ).
2 x2 /2
2
f (x) = p e , 0 < x < 1.
2⇡ ln ST ⇠ N (E(ln ST ), V ar(ln ST )).
Use the acceptance-rejection algorithm to simulate |Z|. Take g to be the exponential distribution, (c)
1. Generate Zi ⇠ N (0, 1).
x 2. Set
g(x) = e , 0 < x < 1. r
1 2 2
⇣ ⌘ T ✓ 2 T 2T )Z
Xi = e lnS0 + (1 e )+ (1 e i.
(a) Determine the value c such that c = max fg(x)
(x)
. 2
(b) Use the acceptance-rejection method to simulate 1000 values of |Z|. 3. Set hi = max(K eXi , 0).
(c) Recover a standard normal distribution from the simulated values of |Z|. Plot its density. 4. Repeat step 1 to step 3 for 10000 times.
e rT
P
10000
5. P0 = 10000 hi .
i=1
(a) ✓ ◆
f (x) 2
c = max = p e1/2
g(x) 2⇡
(b)
1. Generate U1 ⇠ U nif orm(0, 1) and U2 ⇠ U nif orm(0, 1).
2. Set X = ln h U12. i
x 1
3. If U2 exp 2 +x 2 , set Z = X; otherwise return to step 1.
(c)
1. Generate U3 ⇠ U nif orm(0, 1).
2. If U3 < 0.5, set Z = Z; If U3 > 0.5, set Z = Z.
2 3
1 EXERCISES
⇣ ln S0 + (r + 1 2
)T ⌘ ⇣ ln S0 + (r 1 2
)T ⌘ Return
rT K 2 rT K 2
e E[max(ST K, 0)] = S0 p Ke p . Arithmetic return: r(t, T ) = WTWtWt .
T T
Geometric return / Logarithmic return: r(t, T ) = log( W
Wt ) = log(WT )
T
log(Wt ).
Absolute VaR
Absolute VaR: The maximum amount we expect to lose with a given level of confidence.
Abs.VaR in dollar = REV ⇤ , where REV ⇤ is the cut-o↵ revenues/returns conditioning on the
confidence level and the horizon we choose.
Relative VaR
Relative VaR: The maximum amount we expect to lose with a given level of confidence relative to
the mean/expected revenue.
Rel.VaR in dollar = Abs.VaR + Mean Revenue = Mean Revenue – REV ⇤ .
VaR in Return
Abs.VaR in arithmetic return = Abs.VaR in dollar / W ;
Rel.VaR in arithmetic return = Rel.VaR in dollar / W ,
where W denotes the initial value of the portfolio.
⇤ 1155061903@link.cuhk.edu.hk
† Material is based on the previous version by Zhiling GU
4 1
1 VALUE AT RISK (VAR) 2 VOLATILITY CONVERSION OVER DIFFERENT DURATIONS
Hints: µT = µannual T.
0.2103
Absolute VaR for the portfolio over 3 months = 5 5⇥e = $0.9483 million.
2 3
3 ANTITHETIC VARIABLES
3 Antithetic Variables
Idea
Suppose we want to estimate ✓ = E[H(X)], where H(.) is monotone function (either increasing or
decreasing) and X is a random variable. Normally, we can do classic Monte Carlo simulations: RMSC 4001
1 X
2n Simulation Methods for Risk Management Science
HM C = H(Xi ).
2n i=1 and Finance
If we can construct a sequence of antithetic variables Yi such that each Yi has the same distribution Tutorial 9: Variation Reduction Method II Solutions
but negatively correlated with Xi . Then the antithetic estimator of ✓ is
n Liu, Zicheng⇤†
1 X
HAN = [H(Xi ) + H(Yi )].
2n i=1 Department of Statistics, The Chinese University of Hong Kong
If H(Xi ) and H(Yi ) are negatively correlated, then Var(HAN ) is smaller than Var(HM C ).
the antithetic variable method. Your simulation should have 10000 paths in all. 2
c⇤ = Var X · (1 Corr2 (X, Y )).
3
Observe that ✓ = E(eU ), where U ⇠ Unif [0, 1].
1. Generate Ui ⇠ Unif [0, 1] The variance of XCV can be reduced as long as X and Y are not uncorrelated. Without prior
3 3 knowledge of population variances and covariance, we may use sample estimations instead. The
2. Set Xi = eUi and Yi = e(1 Ui ) .
control variate estimate is hence
3. Repeat step 1 to 2 by 5000 times.
5000
1 X d
Cov(X, Y) SXY
4. ✓ = (Xi + Yi ). XCV = X̄ (Ȳ µY ) = X̄ (Ȳ µY ).
10000 i=1 d
VarY SY Y
Remark 1.1. If we want to have more than one control variate, we can use outputs from the
multiple linear regression model by
k
X i.i.d. 2
X =a+ bi Yi + e, e ⇠ N (0, ).
i=1
where µi = E(Yi ).
⇤ s1155061903@link.cuhk.edu.hk
† Modified based on tutorial notes in the past years
4 1
1 CONTROL VARIATE 2 STRATIFIED SAMPLING
R1
Exercise 1.1. Estimate ✓ = 0
3 3
ex dx by considering x2 ex as the control variate. 2 Stratified sampling
Z 1 Z
3 3 1 1 x3 3 1
E(U 2 eU ) = x2 ex dx = e dx = (e 1) = µY . Idea
0 3 0 3
Stratification is the process of dividing members of population into homogeneous subgroups before
1. Generate Ui ⇠ U (0, 1). sampling. The strata should be mutually exclusive: every element in the population must be
3 3
2. Set Xi = eUi and Yi = Ui2 eUi . assigned to only one stratum.
3. Repeat step 1 to 2 by 10000 times.
4. In stratified sampling, we use E(X|Y ) as the estimator of X. This estimator is unbiased because
d
Cov(X, Y) of tower property
✓CV = X̄ (Ȳ µY ).
Vd
ar(Y ) E[E(X|Y )] = E(X).
Also, the variance can be reduced since
Exercise 1.2. Suppose we want to price an arithmetic floating strike Asian put option with payo↵
max(AT ST , 0). For tj+1 tj = t, j = 0, 1, ..., n 1 and tn = T , V ar(X) = E[V ar(X|Y )] + V ar[E(X|Y )] V ar[E(X|Y )]
1
m
X Some notations
At m = St j , 1 m n.
m j=1 • B : number of bins/strata in the sample.
Suppose T = 1, n = 4 and the asset price follows the following dynamics • NB : number of samples in each bin.
• B ⇥ NB : total number of samples.
dSt = rSt dt + St dWt , r = 0.02, = 0.4.
• Xij : the j th sample of ith bin.
The current time is t0 with current asset price St0 = 100. Simulate the Asian option price based on
10000 sample paths using AT as the control variate.
Illustrative generalized example
1h i
Again we want to estimate ✓ = E(X) by stratified sampling by dividing the sample into B strata
µY = E(AT |St0 ) = St0 e0.02/4 + St0 e0.02⇤2/4 + St0 e0.02⇤3/4 + St0 e0.02
4 with equal probability. Suppose we can generate X = F 1 (U ) by inverse transform, then we can
1. Generate stratify the sample X by the following algorithm:
" r # 1
1 2 1 1 iid
1. Generate Vij = B [Ui + (i 1)], i = 1, 2, ..., B, j = 1, 2, ..., NB
S(tj ) = S(tj 1 ) exp (r )( ) + Zj , j = 1, 2, 3, 4, Zj ⇠ N (0, 1).
2 4 4 2. Set Xij = F 1
(Vij ) in each bin.
P4 3. Calculate the sub-sample mean X̄i for each bin.
2. Compute AT = 14 j=1 S(tj ).
3. Set Xi = max(AT St4 , 0) and Yi = AT . 4. Average X̄i over the total number of bins to get the overall estimate of X.
4. Repeat step 1 to 3 10000 times.
5. Asian option price " # The estimate of ✓ is given by
d
Cov(X, Y)
rT NB
pCV = e X̄ (Ȳ µY ) . 1 X
Vd
ar(Y ) (X1j + X2j + ... + XBj ).
B ⇥ NB j=1
2 3
3 IMPORTANCE SAMPLING 3 IMPORTANCE SAMPLING
R1 R R 1)2
Exercise 2.1. Consider ✓ = 2 (x 2)e x dx. It is known that ✓ = E[f (X)] where X ⇠ exp(1). Exercise 3.1. Estimate ✓1 = e |x|
dx and ✓2 = e
(x
8 dx using independent samples following
R R
(a)What is f (X)? N (0, 1).
(b)Provide an algorithm to sample X in [2, 1].
(c) Provide an algorithm and VBA programme to simulate ✓ by stratifying X on the interval [2, 1] with 1. Generate Ui ⇠ N (0, 1).
equal probability 1/4 for each stratified interval. The total sample should be 10000. p Ui2 p (Ui 1)2 Ui2
2. Compute Xi = 2⇡e |Ui |+ 2 , Yi = 2⇡e 8 + 2 .
(a) Z Z 3. Repeat step 1 and 2 for n times.
1 1
x x P
n P
n
✓= (x 2)e dx = (x 2)I(x 2)e dx. 4. Estimate ✓1 = n1 Xi , ✓2 = n1 Yi .
2 0 i=1 i=1
) f (X) = (X 2)I(X 2).
(b) Exercise 3.2. Consider an European call option on a non-dividend paying stock S with the risk-free
Let Y = X 2|X 2. By memoryless property of exponential distribution, Y ⇠ exp(1). instantaneous interest rate r to be a deterministic function of time t. The risk-neutral process of the
Therefore, X|X 2 can be sampled by ln(U ) + 2, where U ⇠ Unif(0, 1). stock and the interest rate movements are
Suppose that the direct generation of X ⇠ F is infeasible. However, there exist another density 4. Repeat step 1 to 3 for 10000 times.
R1 10000
g(x) which is easy to simulate and satisfies exp( 0 r(t)dt) X
5. Price = hi .
10000
f (x) = 0 whenever g(x) = 0. i=1
✓ = E[h(X)]
Z
= h(x)f (x)dx
Z
h(x)f (x)
= g(x)dx
g(x)
h(Y )f (Y )
=E , Y ⇠ G.
g(Y )
Therefore, we can construct a Monte Carlo estimator of ✓ = E[h(X)] by first sampling i.i.d. Yi ’s
with pdf g, and then computing
n
1 X h(Yi )f (Yi )
✓ˆ = .
n i=1 g(Yi )
4 5
Exercise 0.2. Consider evaluating the price of a European call option. Recall that the payo↵ of the
call is positive if and only if Z > L, where
2
1 K
L= [ln( ) (r )T ], Z ⇠ N (0, T ).
RMSC 4001 S0 2
Let Z̃i = L + eZi denote a shifted lognormal random variable, where Zi ⇠ N (µ, ⌘ 2 T ).
Simulation Methods for Risk Management Science
fZ (x)
and Finance (a) Let R(x) =
fZ̃i (x)
, where fZ (x) denote the pdf of a N (0, T ) random variable evaluated at x and
Tutorial 10: Final Revision Solutions fZ̃i (x) denotes the pdf of the shifted lognormal random variable Z̃i evaluated at x. Show that
( " ✓ ◆2 #)
1 ln(x L) µ
Liu Zicheng⇤† R(x) = ⌘(x L) exp x2
2T ⌘
Department of Statistics, The Chinese University of Hong Kong (b) Show that the important sampling estimator based on the pdf of the shifted lognormal distribution
is given by
n
All materials before the midterm exam may be tested. 1X 2
CLN = e rT (S0 exp[(r )T + Z̃i ] K)+ R(Z̃i ).
n i=1 2
Exercise 0.1. Provide the simulation algorithms for the following methods to generate a bivariate
normal random vector (X1 , X2 ) with zero means, unit variances and a correlation of -0.6.
(a) The cdf of Zei is
1. Cholesky decomposition;
✓ ◆
log(z L) µ
2. Gibbs sampling; P(Zei z) = P(L + eZi z) = P(Zi log(z L)) = p
⌘2 T
3. Metropolis-Hastings algorithm with proposal distributions
for z > L. Therefore, the density function is
X1 ⇠ N (X2 , 1) and X2 ⇠ N (X1 , 1). ✓ ◆ ⇢ ✓ ◆2
log(z L) µ 1 log(z L) µ
p exp 2
p 2
d ⌘2 T ⌘ T
(i) (i) i.i.d. fZei (z) = P(Zei z) = p = p
1. Step 1: Generate Z1 , Z2 ⇠ N (0, 1). dz (z L) ⌘2 T (z L) 2⇡⌘ 2 T
(i) (i) (i) (i) (i)
Step 2: Take X1 = Z1 , X2 = 0.6Z1 + 0.8Z2 .
Step 3: Repeat Steps 1 and 2 for i = 1, 2, 3, · · · , n. for z > L. Hence,
⇢ ✓ ◆2
(0) (0)
2. Step 1: Initialize X1 , X2 . ✓ ⇢ ✓ ◆2 ◆ ✓ exp 1 log(x L) µ
p 2 ◆
(i) (i 1) fZ (x) 1 1 x 2 ⌘ T
Step 2: Generate X1 ⇠ N ( 0.6X2 , 0.64). R(x) = = p exp p p
(i) (i) fZei (x) 2⇡T 2 T (x L) 2⇡⌘ 2 T
Step 3: Generate X2 ⇠ N ( 0.6X1 , 0.64). ⇢
Step 4: Repeat Steps 2 and 3 for i = 1, 2, 3, · · · , n. 1 2 log(x L) µ 2
= ⌘(x L) exp [x ( ) ] .
Step 5: Discard the first k burn-in samples. 2T ⌘
(0) (0) (b)
3. Step 1: Initialize X1 , X2 .
(i 1) (i 1)
Step 2: Generate Y1 ⇠ N (X2 , 1) and Y2 ⇠ N (X1 , 1). ⇥ 2 ⇤
rT
Step 3: Generate U ⇠ Unif[0,
✓ 1]. h⇣ ⌘ i ◆ C = e EZ (S0 exp{(r )T + Z)} K)+
2
1 (i
X1
1) 2 (i
+X2
1) 2
+1.2X1
(i 1) (i
X2
1)
(Y12 +Y22 +1.2Y1 Y2 ) Z 1 2
Step 4: Compute ⇢ = min e 2⇥0.82 ,1 . rT
= e (S0 exp{(r )T + z)} K)+ fZ (z)dz
Step 5: If U < ⇢, then take X (i) = Y . Otherwise, take X (i) = X (i 1)
. L 2
Z 1 2
Step 6: Repeat Steps 2 to 5 for i = 1, 2, 3, · · · , n. rT fZ (z)
= e (S0 exp{(r )T + z)} K)+ f e (z)dz
Step 7: Discard the first k burn-in samples. L 2 fZei (z) Zi
2
= e rT
EZei (S0 exp{(r )T + Zei )} K)+ R(Zei ) .
2
1 2
Exercise 0.3. Consider the spread weighted average option whose payo↵ is Exercise 0.4. A non-divended paying stock S has a time-deterministic volatility. It is postulated that
3 4