Cmda3606 HW2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CMDA 3606, Spring 2015

Homework 2

Dr. Chung

Due Thursday February 26, 2015, 2:00PM


1. Data Approximation: We are given measurements of air pollution, in the form of the
concentration of NO, over a period of 24 hours, on a busy street in a major city. Since
the NO concentration is mainly due to the cars, it has maximum values in the morning
and in the afternoon, when the traffic is most intense. The data is shown in the following
table:
ti
0
1
2
3
4

yi
110.49
73.72
23.39
17.11
20.31

ti
5
6
7
8
9

yi
29.37
74.74
117.02
298.04
348.13

ti
10
11
12
13
14

yi
294.75
253.78
250.48
239.48
236.52

ti
15
16
17
18
19

yi
245.04
286.74
304.78
288.76
247.11

ti
20
21
22
23
24

yi
216.73
185.78
171.19
171.73
164.05

For further analysis of the air pollution we need to fit a smooth curve to the measurements, so that we can compute the concentration at an arbitrary time between 0 and
24 hours. For example, we can use a low-degree polynomial to model the data, i.e., we
assume that the NO concentration can be approximated by
f (t) = x1 tp + x2 tp1 + . . . + xp t + xp+1 ,
where t is the time, p is the degree of the polynomial, and x1 , x2 , . . . xp+1 are the unknown
coefficients in the polynomial. A better model however, since the data repeats every day
would use periodic functions:
f (t) = x1 + x2 sin(t) + x3 cos(t) + x4 sin(2t) + x5 cos(2t) + . . .
where = 2/24 is the period. Again, x1 , x2 , . . . are the unknown coefficients. The
goal of data fitting is to estimate the coefficients x1 , x2 , . . ., so that we can evaluate the
function f (t) for any argument t.
(a) Derive the least squares problem for both the polynomial fit with polynomial of
degree p = 8 and the trigonometric fit with 9 functions. (Note: In both cases, there
are 9 unknowns.) Make sure to provide the sizes of the design matrices.
(b) Use Matlab to solve the corresponding normal equations.
(c) In Matlab, create two figures: one that plots the data points along with the polynomial least squares fit on the same graph and another that plots the data points
along with the trigonometric least squares fit on the same graph. Which approach
is better and why?
2. Recall the example of image compression using the singular value decomposition that
we saw in class. Now we want to compress a larger image.

(a) Load an image into Matlab (the image should be 256 256 or larger) and display
the image in a figure. You can select from Matlabs built in images, or pick another
image you like. If your image is in color, convert it to grayscale. What is the size
and rank of your image? (Hint: Use rank(A) to determine the rank of a matrix in
Matlab)
(b) Compute the SVD of A and plot the singular values of A. What do you notice
about the decay of the singular values? Are there a few singular values that are
much larger than the rest?
(c) Next we would like to compress this image with truncated singular value decompositions. Compute compressions of your image using truncated SVDs Ak for various
values of k. What do you notice about the images as k tends to the computed rank?
(d) The two images shown in Figure 1 show characters generated in the MinionPro
italic font, defined in the image files minionamp.jpg and minion11.jpg, each of
which leads to a 200 200 matrix. Which image do you think will better lend
itself to low-rank approximation? Compute the singular values and truncated SVD
approximations for a variety of ranks k. Do your results agree with your intuition?

Figure 1: Two images showing characters in the italic MinionPro font. (The first is an
ampersand, which one can clearly see here derives from the Latin word et, meaning and.)

Page 2 of 2

You might also like