MA323 Computational Methods in Financial Mathematics
Computational Methods in Financial Mathematics
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
MA323 Computational Methods in Financial Mathematics
1 Guidelines
Note in particular: Five marks (out of 100) will be deducted for coursework submitted within
24 hours of the deadline and a further five marks will be deducted for each subsequent 24-hour
period until the coursework is submitted.
After five working days, coursework will only be accepted with the permission of the Chair
of the Sub-Board of Examiners.
• Please submit your complete report together with all files to [email protected].
Include “MA323 submission” in the subject line.
• For the submission please only submit one zip-file that contains all your files except
the Plagiarism Statement, which you should submit in the same email. Your zip-
file should have the following name: If your candidate number is 123456, then name your
zip-file MA323 CN123456.zip.
Your zip-file must contain your Jupyter Notebook (please provide an ipynb file, which the
examiners can run, and a pdf version of it.) You should name these files according to your
course code and candidate number, e.g., MA323 CN123456report.ipynb.
• The content of your work must remain anonymous, so do not write your name on anything ex-
cept the Plagiarism Statement. Instead, you must identify your work with your Examination
Candidate Number. You can check your candidate number on ‘LSE for You’.
1.2 Academic integrity
• When you submit the coursework you must submit a completed and signed copy of the
Plagiarism Statement (available on Moodle).
Note in particular the first paragraph on this website:
“All work for classes and seminars (which could include, for example, written assignments,
group work, presentations, and any other work, including computer programs) must be the
student’s own work. Direct quotations from other work must be placed properly within
quotation marks or indented and must be cited fully. All paraphrased material must be
clearly acknowledged. Infringing this requirement, whether deliberately or not, or passing off
the work of others as the student’s own work, whether deliberately or not, is plagiarism.”
• You must take this assessment completely alone and not show or discuss it with anyone else.
• This is an open book assessment and you are allowed to use any material made available on
Moodle for MA323 and any academic literature as long as you cite the material that you use
fully.
• You are not permitted to: consult any other person about the content of the assessment;
allow any other person to edit or proof read your work; submit any ideas or phrasing that
are not your own (without appropriate citation).
• You should not include any writing of your own that has been submitted for a different
summative assessment.
• The examiners may conduct vivas to check that you were the author of your submitted
assessment.
1.3 Specific guidelines on report
• The coursework consists of four problems. Your answers to all four problems will count
towards the final mark.
• Write a report and not just a question-answer style exercise set solution to answer the ques-
tions. Your report should contain all results and their derivation, interpretation and discus-
sion. Use complete sentences throughout. Give detailed arguments to explain your ideas and
carefully justify your answers.
• The only acceptable programming languages are Python 3.7, 3.8, 3.9, or 3.10.
• Please only provide one notebook. Separate answers to the different questions clearly in this
notebook.
• Your submitted Jupyter notebook should run completely without any error messages.
• In particular, note that your Jupyter notebook should NOT ask the user to enter variables
needed for the computation. Choose reasonable default parameters yourself and make clear
in your instructions what the meaning and the names of the variables are such that the
examiners can test several examples.
• Add appropriate comments to your code to explain what your code is doing.
• Your figures should be well formatted, with good axis labelling and appropriate titles.
1.4 Assessment
2 Coursework Description
If you use a random number generator for any of the problems below, seed the generator so that
the results are reproducible.
Problem 1. Consider the two integrals
I1 =
∫ 4
0
1
(2 + cos(x))2
dx;
I2 =
∫ ∞
0
x3/2e−x
2/2dx.
(a) Describe a numerical method to approximate the value of I1 such that the approximation error
is guaranteed to be bounded by 1/100. Implement this method in Python and provide the value
of the approximation.
(b) Explain how one can approximate the integral I2 using a Monte Carlo estimator. Implement
the Monte Carlo estimator in Python and provide a figure that plots a Monte Carlo estimate
against the number of samples (as we have done in the lectures and programming sessions).
Describe a variance reduction technique that can be applied here and discuss how well this
technique works in this example.
Problem 2. Consider the function f : R→ R given by
f(x) =
{
α√
1+x
, if x ∈ (0, 3),
0, if x /∈ (0, 3),
where α is a constant.
(a) Determine α such that f is a probability density function.
(b) Let α be the constant such that f is a probability density function (i.e., the one computed
in part (a)). Suppose you would like to generate a sample from f using von Neumann’s
acceptance-rejection algorithm. Specify a probability density function g 6= f that can be used
for this purpose and describe in detail how you can obtain a sample from f by sampling
from g using von Neumann’s acceptance-rejection algorithm. For your choice of g what is the
best possible proportion of numbers that your algorithm accepts? Implement von Neumann’s
acceptance-rejection algorithm in Python to obtain 10000 samples from f and plot a histogram
of the samples.
(c) An alternative to von Neumann’s acceptance-rejection algorithm from part (b) for sampling
from f would be to use the inverse transform method. Implement it in Python and draw again
a histogram of the samples. Which of these two methods do you think is more suitable for
generating a sample from f and why?
Problem 3. We consider the standard Black-Scholes financial market consisting of two assets.
The riskless asset has time-t price Bt = e
rt, where r ≥ 0 is the constant interest rate and the stock
has time-t price
St = S0 exp
((
r − σ
2
2
)
t+ σWt
)
,(1)
where S0 > 0 is the initial stock price, σ > 0 is the volatility, (Wt)t≥0 is a standard one-dimensional
Brownian motion under the risk-neutral measure.
Fix a constant K > 0 and consider a European option with payoff H at the maturity date T > 0
given by
H = |ST −K|.(2)
(a) Derive an analytical formula for the time-0 price of this option.
(b)(b.1) Write down a Monte Carlo estimator for the time-0 price of this option. Justify your
answer.
(b.2) Explain in detail how one can generate the random variables that are used in your Monte
Carlo estimator in part (b.1).
(b.3) Compute the variance of the Monte Carlo estimator for the time-0 price of the option
analytically.
(b.4) Write down a 95% and a 99% asymptotic confidence interval for the time-0 price of the
option using your Monte Carlo estimator.
(c) Write Python code
(c.1) that computes the time-0 price of the option using the analytical formula and
(c.2) that computes the approximation of the time-0 price of the option using a Monte Carlo
estimator together with an asymptotic confidence interval.
(d) Use your Python code to compute the time-0 price of the option for the model parameters
S0 = 4, K = 5, r = 0.01, σ = 0.2, T = 1 using both the analytical formula and the Monte
Carlo estimator. Provide a 95%-asymptotic confidence interval for the time-0 price of the
option. Discuss your results.
(e) Describe a variance reduction method to approximate the time-0 price of the option and im-
plement it in Python. Compare the results based on the variance reduction method of your
choice to the standard Monte Carlo estimator and to the analytical solution. Discuss your
findings.
Problem 4. This question continues the previous one, but now we leave the world of the Black-
Scholes model. We still assume that the time-t price of the riskless asset is given by Bt = e
rt with
r ≥ 0. However, we now assume that the dynamics under the risk-neutral measure of the risky
asset are given by
dSt = rStdt+ σ(1 + St)dWt,(3)
where (Wt)t≥0 is again a Brownian motion under the risk-neutral measure and σ > 0. In case the
stock price hits zero we assume that it stays at zero. As before we assume S0 > 0.
(a) Explain how you can generate a sample path of S = (St)t≥0 given in (3) on the discrete time
grid 0 < h < 2h < . . . < nh for h > 0, n ∈ N. Write Python code that provides samples of
ST . Create a plot with ten sample paths of (St) for S0 = 4, r = 0.01, σ = 0.2, and T = 1
with h = 1/250.
Additional detail: It might happen that your approximation of Sih for some i ∈ {1, 2, . . . , 2}
becomes negative. Whenever this happens you should replace your approximation by zero.
(b) Fix a constant K > 0 and consider a European option with payoff H at the maturity date
T > 0 given by
H = |ST −K|.(4)
Write down a Monte Carlo estimator for the price of this option if the stock price is given by
the dynamics in (3). Justify your answer.
(c) Write Python code that computes the approximation of the time-0 price of the option using
a Monte Carlo estimator together with an asymptotic confidence interval. Use your Python
code to compute the time-0 price of the option for the model parameters S0 = 4, K = 5,
r = 0.01, σ = 0.2, T = 1 using the Monte Carlo estimator. Provide a 95%-asymptotic
confidence interval for the time-0 price of the option. Discuss your results.
(d) Specify two control variate estimators, that differ in the choice of the random variable used as
control, for approximating the time-0 price of the option with payoff (4) under the dynamics
of (3) and implement them in Python. Compare the results based on these two control variate
estimators and the standard Monte Carlo estimator. Discuss your findings.