QBUS1040 Tutorial 6 Semester 2, 2022
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
QBUS1040
Tutorial 6
Semester 2, 2022
Exercise 1: Linear independence
For each of the following matrices, determine which response is correct.
(a)
l 「1047 45 −471
• The columns are linearly independent
• The columns are linearly dependent.
• This is not an appropriate question.
(b)
768 1121 −2095 −9284 4093 −3490
834 1428
• The columns are linearly independent
• The columns are linearly dependent.
• This is not an appropriate question.
245 −784 781 −128 349 −721 |
」 781 |
3425 5821 −7249 4392 23450 |
8023 」
−293 |
Exercise 2: Difference from trailing three-day rolling average
The n-vector p gives the daily time series of the price of an asset over n trading days, with n ≥ 4 The (n − 3)-vector d gives the difference of the current asset price and the average asset price over the previous three trading days, starting from the fourth day. Specifically, for i = 1, ...,n − 3, we have di = pi+3 − (pi + pi+1 + pi+2)/3. (Note that d is an (n − 3)-vector.) Give the matrix A for which d = Ap, for the specific case n = 6. Be sure to give its size and all entries.
Remark. Time series similar to d are used in some simple trading schemes, which buy or sell the asset depending on whether the price is high or low compared to a trailing multi-day rolling average.
Exercise 3: Linear functions of images
In this problem we consider several linear functions of a monochrome image with N × N pixels. To keep the matrices small enough to work out by hand, we will consider the case with N = 3 (which would hardly qualify as an image). We represent a 3 × 3 image as a 9-vector using the ordering of pixels shown in Figure 1. (This ordering is called column-major.) Each of the operations or trans- formations below defines a function y = f(x), where the 9-vector x represents the original image, and the 9-vector y represents the resulting or transformed image. For each of these operations, give the 9 × 9 matrix A and the transformed image y for which y = Ax.
1 |
4 |
7 |
2 |
5 |
8 |
3 |
6 |
9 |
Figure 1: Column-major ordering of pixels for a 3 × 3 image.
(a) Rotate the original image x clockwise 90 degrees.
(b) Set each pixel value yi to be the average of the neighbours of pixel i in the original image. By neighbours, we mean the pixels immediately above and below, and immediately to the left and right. The centre pixel has 4 neighbours; corner pixels have 2 neighbours, and the remaining pixels have 3 neighbours.
Exercise 4: Norm of a matrix: Code it up!
Compute the norm of a matrix using for loops in Python. Verify your results with np .linalg .norm(A). Use your code on a large matrix and time your operation.
Exercise 5: Matrix vector multiplication: Code it up!
Perform matrix-vector multiplication using for loops in Python. Verify your results with np .matmul(A, x) and A @ x. Use your code on a large matrix and time your operation.
2022-09-20