Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
18 views4 pages

Homework 3 Spring 2025

The document outlines the homework assignments for MTH4320: Computational Finance for Spring 2025, including various problems related to probability mass functions, factorial calculations, investment analysis using MATLAB, matrix operations, and plotting parametric equations. Each problem has specific tasks and point values assigned, with a focus on programming and computational techniques. The homework is due on February 27th.

Uploaded by

Jérôme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Homework 3 Spring 2025

The document outlines the homework assignments for MTH4320: Computational Finance for Spring 2025, including various problems related to probability mass functions, factorial calculations, investment analysis using MATLAB, matrix operations, and plotting parametric equations. Each problem has specific tasks and point values assigned, with a focus on programming and computational techniques. The homework is due on February 27th.

Uploaded by

Jérôme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MTH4320: COMPUTATIONAL FINANCE — Spring 2025

Homework 3: due on February 27th

Problem 1: (22pts)

Assume we have available a fair die with outcomes, 1, 2, 3, 4, 5, and 6 and with
1
probability mass function p(1) = p(2) = p(3) = p(4) = p(5) = p(6) = .
6

– This die is rolled 4 times in row and the 4 outcomes are added. Compute the
X1 + X 2 + X3 + X 4
probability mass function of the random variable, X = . Plot
4
this probability mass function using either the hist, bar, barh function. (4pts)

– This die is rolled 16 times in row and the 16 outcomes are added. Compute the
X1 + X2 + · · · + X16
probability mass function of the random variable, X = . Plot
16
this probability mass function using either the hist, bar, barh function. (4pts)

– This die is rolled 64 times in row and the 64 outcomes are added. Compute the
X1 + X2 + · · · + X64
probability mass function of the random variable, X = . Plot
64
this probability mass function using either the hist, bar, barh function. (4pts)

X1 + X2
You are strongly encouraged to write a script that compute the average, X = ,
2
of two identically distributed random variables with the same general probability mass

function with p(xi ) = pi , for i = 1, · · · , n and such that pi ≥ 0 and p1 +p2 +· · ·+pn = 1.

You should make use of this functional script to answer the (a), (b), and (c).

Problem 2: (12pts)

(a) Write a function script to compute the factorial function and use it to compute 9!.

(4pts)

1
(b) Write a recursive function script to compute the factorial function and use it to compute

12!. (2pts)

(c) Write a function script that determine the first (smallest) n such that factorial of n is

higher than some predetermined value m. Provide your solution for m = 5000, 50, 000,

and 500, 000. Provide also the factorials of the corresponding n − 1’s and n + 1’s, one

for each of three scenario. (6pts)

Problem 3: (28pts)

An investor is contemplating investing into the following annual cash flows.

0 1 2 3

Investment 1 -$13,000 $5,000 $6,000 $7,000

Investment 2 -$13,000 $7,000 $4,800 $6,000

(a) Which one would you recommend to him if the prevailing annual compounded

discounting rate is 4.5% and 9.0%? To answer this question, you have to use the

polyval function in Matlab. Write a Matlab script to carry out this task. (10pts)

(b) Find the internal rates of return of investment 1 using the roots function in Mat-

lab. Write a Matlab script to carry out this task. (3pts)

(c) Find the internal rates of return of investment 2 using the roots function in Mat-

lab. Write a Matlab script to carry out this task. (3pts)

(d) Find the discounting rate that makes the two investments equal to each other

using the roots function in Matlab. Write a Matlab script to carry out this task.

(5pts)

2
(e) Write a script to draw the NPV curves of these two investments on the same

graphical display. Draw a vertical line at each of these three five discounting

rates. Add a grid, labels, legend, and title to the graph. (7pts)

Problem 4: (13pts)

(a) Write a function script that sorts in ascending order the column-wise entries in a

matrix. Use the sort function in MATLAB to carry out this task. (2pts)

(b) Write a function script that computes the number of positive entries of the matrix.

Use the sum function in MATLAB to carry out this task. (2pts)

(c) Write another function script that computes the number of positive entries of the

matrix. Using two loops (one nested in the other one) together with an if statement

to check if each entry of the matrix is a positive number. (3pts)

(d) Test your script codes in (a), (b) and (c), by generating three random matrices, A, B

and C, the matrix A of size 5 × 5, the matrix B of size 10 × 10 and the matrix C of

size 20 × 20. (3pts)

(e) Test again your code with abs(A), abs(B), abs(C). (3pts)

Problem 5: (22pts)

The butterfly curve given by the following parametric equations.

( )
x(t) = sin(t) ecos(t) − 2 cos(4t) − sin5 (t/12)
( )
y(t) = cos(t) ecos(t) − 2 cos(4t) − sin5 (t/12) .

1
(a) Generate values of x(t) and y(t) for t from 0 to 100 with ∆t = . (2pts)
32

3
(b) Construct the plot of x(t) vs t and that of y(t) vs t in the same graphical area employing

a dotted line for y(t) in order to distinguish. Include title and axis labels on all plot

as well as a legend. (10pts)

(c) Construct the plot of x(t) vs y(t) in square. Include title and axis labels on the plot

as well as a legend. (4pts)

(d) Construct the 3-D plot of t vs x(t) vs y(t). Include title and axis labels on the plot as

well as a legend. (6pts)

Problem 5: (3pts)

Write a functional script that gives the number of days in a given month in 2021 using

the switch-case statement. For example, the month of January has 31 days and the

month of November has 30 days.

You might also like