Description
1. Use the inverse transform method to produce a standard Cauchy distributed random
variable X with density
fX(x) = 1
π(1 + x
2
)
from a standard uniformly distributed one, U ∼ U
[0, 1)
:
a) Calculate the (generalized) inverse cdf F
−1
X of X.
b) Sample the Cauchy distribution numerically by creating a histogram for x ∈ [−5, 5)
and bin size 1
10 with 10,000 samples and compare it to a direct plot of the density f.
2. Show that the Box-Muller algorithm
X
1 = cos(2πU1
)
p
−2 log U2
X
2 = sin(2πU1
)
p
−2 log U2
produces indeed two independent standard normal random variables from independent
uniform ones
2
3. Use the acceptance rejection method to produce a sample of a folded normal random
variable X with density
fX(x) = (
√
2
2π
e
− x
2
2 if x > 0;
0 else,
by using an exponential density as dominating term.
a) Choose a reasonably small constant c such that cg(x) ≥ f(x) for all x ∈ R.
b) Plot the density of your trial by plotting a histogram for x ∈ [0, 3) and bin size 1
10
with 10,000 samples and compare it to a direct plot of the density f.
4. The Marsaglia–Bray method is an alternative method to generate a normal distribution
out of a uniform sample, using the acceptance-rejection method: Using two independent
standard normal distributed random variables, U
1
, U
2 ∼ U
[0, 1)
, we set V
1 = 2U
1 − 1
and V
2 = 2U
2 − 1, and calculate S =
V
1
2
+
V
2
2
. If S ≥ 1 we reject the sample,
otherwise we calculate
X
1 = V
1
r
−2 log S
S
;
X
2 = V
2
r
−2 log S
S
.
Prove that X1 and X2 are standard-normal distributed random variables.
Note: The Marsaglia–Bray algorithm is superior to Box-Muller as it uses only one
computationally expensive transcendental functions (namely log) instead of three (log,
sin and cos), at the price of having a part of the sample rejected.
Bonus question: Which percentage of the sample gets rejected?
5. Compare the Box–Muller and the Marsaglia–Bray algorithm (see problem 2 and 4) by
using them to produce samples of standard-normal distributed random variables from
uniform random variables given by the built-in random number generator of your
programming language. Compare the densities of your samples generated by the two
methods with each other and the exact normal density function by plotting a histogram
for x ∈ [−3, 3) and bin size 1
10 . Choose the sample size in a way that the runtime of the
slower algorithm is between 1s and 10s (just using trial and error) and compare the
runtim
3
6. Assume a financial markets where stock and money market account follow the dynamics
dSt = µSt dt + σSt dWt
, S0 = 100;
dBt = rBt dt, B0 = 1,
with µ = 0.05, σ = 0.2 and r = 0.03.
(a) Calculate the price of a European put option with maturity T = 0.5 and strike
K = 110 using the Black–Scholes formula.
(b) Calculate the price of a European put option with maturity T = 0.5 and strike
K = 110 using Monte-Carlo integration.
(c) Compare the results of part (a) and part (b), using different sample sizes for the
Monte-Carlo integration. Make a plot that shows the numerically computed option
price as function of the sample size.
(d) Calculate the price of a European asset-or-nothig digital call option (payoff
ST 1l{ST >K}) option with maturity T = 0.5 and strike K = 110 using Monte-Carlo
integration.
(e) Calculate the price of a European cubic put option (payoff
(K − ST )
+
3
) option
with maturity T = 0.5 and strike K = 110 using Monte-Carlo integration.
(f) Calculate the price of a European gap call option (payoff (ST − L)
+1l{ST >K})
option with maturity T = 0.5 and strike K = 110 and exercise level L = 105 using
Monte-Carlo integration.
(g) Calculate the price of a European exponential put option (payoff e
(K−ST )
+
) option
with maturity T = 0.5 and strike K = 110 using Monte-Carlo integration.
Bonus question: Which of the options of problem (d)–(g) admit a closed-form
representation of the option price?
Note: All programming problems should be either in Python 2.7 (recommended) or
Python 3.5, matlab, or R (no support for these languages provided). Please comment
the programs extensively and send them in a .zip file with title Lastname HW2.zip and
suject line ”MA 573 HW2 Lastname” to Qingyun Ren qren@wpi.edu before the due
date of the homework (replacing the bold words by your actual last name). Plots can be
provided either as printout or as .pdf file.
4 points per problem


