MATH6005 Final Assignment 1 Instructions
Your Final Assignment will count for 80% of the assessment for MATH6005. The deadline is 23:59 on Tuesday 12-Jan-2021. The deadline is strict. Assignments handed in after this time is not allowed, except where special considerations apply. Ensure that you take frequent and multiple backups of your work, since excuses concerning lost or corrupted files will not be treated sympathetically. Please, verify that you follow all instructions carefully and your work has been uploaded successfully.
1.1 Electronic submission
The electronic submission through Blackboard should be your code in a single .py file. ONLY one .py file is acceptable, please put all tasks into this file, and run once to print all results. Other types of files including ’.ipynb’, ’.txt’, ’.pdf’ are not acceptable.
Please, name your file with the pattern: file extension student number For example, a student with student number 12345678 must submit the file: PY 12345678.py
Ensure that your name does not appear anywhere in your submission.
Your code should be submitted via Blackboard by the deadline above.
Please keep a copy of your project in case there is a problem with the file you submit.
You will have at most two attempts for the submission. The latest attempt will be marked.
Submissions that do not meet the above requirements will affect the final marks.
1.2
1.3
Collaboration, plagiarism and cheating
You should work on your own when carrying out the assignment.
Please refresh your memory of the University’s code on academic integrity, see University of Southampton Calendar 2020/21
Please note that allowing somebody else to copy your work is counted as plagiarism: it carries the same penalty as copying work.
Submissions will be strictly tested for plagiarism with specialised software and penalties strictly enforced.
Purpose of assessment
The purpose of this assignment is to assess your ability to:
Write a structured computer program.
Demonstrate good and correct use of Python.
Demonstrate good programming practice, as discussed in the course notes, lectures and
computer workshops.
1
1.4 Marking
The weighting is broken down as follows:
Adhering to the interface specification (correct function names, 10%).
Functions run without error and provide correct answers to tests (90%). 2 Assignments
The Assignment consists of three Tasks. Mark is divided as 25%, 25% and 30%.
Task 1 statistics analysis (25%)
Given a csv file, Task1_covid19_new_cases, you are expected to summarize some statistics.
Task 1.1 (5%). Read the data into dataframe.
Task 1.2 (15%). Divide the data into 4 groups by nations. For each group, you need to
– find the dates of maximum number of new cases. If the dates are not unique, print all of them;
– find the dates of minimum non-zero number of new cases. If the dates are not unique, print all of them;
– compute the average value of new cases for each month.
Task 1.3 (5%). Find a proper way to present the average value of new cases per each month
each nation in ONE figure.
Task 2 text data manipulation (25%)
Given a text document, Task2_rand_words_text.txt, your task is to
Task 2.1 (10%). Read the text and count the frequency of words appearing in the text. The data should be sorted by the frequency in a decreasing order.
Task 2.2 (5%). Draw a bar plot (Word v.s. Frequency), and then try to beautify the plot.
Task 2.3 (10%). Rewrite the text as a sequence of numbers representing the order of the
word frequency.
For example: if the given text is
cat may car dog may car cat cat dog may dog dog
then the outcome of Task 2.1 should be:
Index Word Frequency 0 dog 4
1 cat 3
2 may 3
3 car 2 2
and the outcome of Task 2.3 is:
123023110200
Task 3 scientific computing (30%)
In this task, you are expected to code the Newton’s method which is famous for finding solutions to equation system
h1(x) H(x):= h2(x) =0.
· · · hn (x)
Here x is the n-dimensional array, namely x = (x1, x2, · · · , xn). The Jacobian matrix of H(x) is ∂h1(x) ∂h1(x) ··· ∂h1(x)
∂x1 ∂x2 ∂xn ∂h(x) ∂h(x) ∂h(x) 22···2
∇H(x) = ∂x1 ∂x2 ∂xn . ···
∂hn(x) ∂hn(x) · · · ∂hn(x) ∂x1 ∂x2 ∂xn
where ∂hi(x) is the partial derivative of hi at xj, i,j = 1,2,··· ,n. The framework of Newton’s ∂xj
method is summarized in Algorithm 1. Algorithm 1: Newton’s Method
Initialize x0 and tol = 10−10, the maximum number of iterations maxit = 100. Set k ⇐ 0. while ∥H(xk)∥2 ≥ tol and k ≤ maxit do
Update xk+1 = xk − (∇H(xk))−1H(xk) Set k ⇐ k + 1
end
Output the solution xk. Here, the 2-norm is
∥ x ∥ 2 = x 21 + x 2 2 + · · · + x 2n ,
which can be calculated by np.linalg.norm. For the while loop, if one condition ∥H(xk)∥2 <
tol is met, then we stop the algorithm. This is because
∥H(xk)∥2 =h21(xk)+···+h2n(xk)