Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

854G1

MMath/MSc LEVEL 7 EXAMINATIONS 2023

MATHEMATICS: COMPUTING FOR DATA ANALYTICS AND FINANCE

Assessment Period: January 2023 (A1) 

1.  (a)  Input the following matrix into MATLAB:                                                                         [12 marks]

A=[2,  1,  1;  -1,  3,  1;  4,  1,  2]

In each case write down the MATLAB commands used and the solution

i.  Calculate B if A + B = [10, 12, 3; 10, 9, 1; 1, 1, 8]

ii.  Calculate AAT  where AT  denotes the transpose of A

iii.  Calculate the inverse of A

iv.  Calculate AA1 where A1  denotes the inverse of A

v.  Calculate the determinant of A

vi.  Calculate the eigenvalues of A.

(b)  Denote by N0  the set of all nonnegative integers {0, 1, 2, ...}.                                              [10 marks]

Assume that the force of interest g(n) is defined as

g(n) := (1.05)n ,

and that s(n) is a function associated with linear returns that is defined, for P0  * 0, as

s(n) :=   ,

where i = 0, 1, ..., n, and Pi  is a given number that represents the price at time i. Write down the recursive definitions, stating both the base case and the recursive step for the functions g(n) and s(n), which are functions of n ∈ N0. Remember that 1  is the summation over all integers 1 ≤ i n, and that the base case for both isn = 0.

(c)  For each of the functions g and s in part (b), write a corresponding MATLAB code, checking it is correct by implementing it for values n  =  1, 2, 3, 5 and  10.  For the

functions, assume that the price at time i is given by Pi  = 1 + i.                                      [8 marks]

2.  A customer takes out a loan of value L and agrees to repay the loan over N years on the basis of a nominal rate of interest r payable monthly (i.e. the effective rate of interest on   each of equal value P, until the loan is repaid in full.

(a)  Letting μ = (1 +  fractions of years) taken to repay the loan is given by

N  log  .                                              (1)

Make sure you carefully define all quantities you introduce, and ensure you state any relation between the quantities given in (1), in the proper financial context.     [9 marks]

(b)  Explain why formula (1) holds even though there is no base given for the logarithm. [6 marks]

(c)  Setting log to be the natural logarithm appearing in display (1), write a MATLAB function that will compute N given Pr and L.  How long in years would it take to pay off a loan of £70000 at £745 a month with a nominal interest rate on monthly transactions of 12%?                        [8 marks]

(d)  Use MATLAB to create a plot of the function you have written in (c).  What is the smallest monthly payment that can be made in order to repay the loan off in a finite time? [7 marks]

3.  The exponentially weighted moving average with weight α  ∈ (0, 1], of a sequence of real numbers (xn )nN0    (e.g, stock prices at the close of each working day n), is defined recursively as

EWMA(α, xn) := ( αxn  + (1 α) EMWA(α, xn 1f(f)   n(n)  0(0),             (2)

(a)  Using the idea of recursion, or otherwise,write a code implementing EWMA that will take the parameter α and a vector x as inputs, and return a vector of exponentially moving averages.           [10 marks] 

(b)  Briefly describe what the built in MATLAB function randn does. Use it to produce a test sequence of length 256, and call it x.         [5 marks] 

(c)  Test the function EWMA in part (a) on the sequence produced in (b) with a driver script.        [2 marks] 

(d)  Plot a figure with the original sequence x and the sequence

α  := (EWMA(α, xn))n= 1,2,...,256

for each α = 0.25, 0. 125 and 0.0625. Include a legend.                          [8 marks] 

(e)  What are the limits of the sequence α  = EWMA(α, x) as α → 1 and as α → 0? Give a mathematical explanation and test this with your scripts and functions from parts

(a), (b),(c) and (d) above.                                             [5 marks]