CMDA3606_HW2

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: t i y i t i y i t i y i t i y i t i y i 0 110.49 5 29.37 10 294.75 15 245.04 20 216.73 1 73.72 6 74.74 11 253.78 16 286.74 21 185.78 2 23.39 7 117.02 12 250.48 17 304.78 22 171.19 3 17.11 8 298.04 13 239.48 18 288.76 23 171.73 4 20.31 9 348.13 14 236.52 19 247.11 24 164.05 For further analysis of the air pollution we need to fit a smooth curve to the measure- ments, 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)= x 1 t p + x 2 t p-1 + ... + x p t + x p+1 , where t is the time, p is the degree of the polynomial, and x 1 ,x 2 ,...x p+1 are the unknown coefficients in the polynomial. A better model however, since the data repeats every day would use periodic functions: f (t)= x 1 + x 2 sin(ωt)+ x 3 cos(ωt)+ x 4 sin(2ωt)+ x 5 cos(2ωt)+ ... where ω =2π/24 is the period. Again, x 1 ,x 2 ,... are the unknown coefficients. The goal of data fitting is to estimate the coefficients x 1 ,x 2 ,..., 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 poly- nomial 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.

description

Homework from VT CMDA 3606

Transcript of CMDA3606_HW2

Page 1: CMDA3606_HW2

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 theconcentration of NO, over a period of 24 hours, on a busy street in a major city. Sincethe NO concentration is mainly due to the cars, it has maximum values in the morningand in the afternoon, when the traffic is most intense. The data is shown in the followingtable:

ti yi ti yi ti yi ti yi ti yi0 110.49 5 29.37 10 294.75 15 245.04 20 216.731 73.72 6 74.74 11 253.78 16 286.74 21 185.782 23.39 7 117.02 12 250.48 17 304.78 22 171.193 17.11 8 298.04 13 239.48 18 288.76 23 171.734 20.31 9 348.13 14 236.52 19 247.11 24 164.05

For further analysis of the air pollution we need to fit a smooth curve to the measure-ments, so that we can compute the concentration at an arbitrary time between 0 and24 hours. For example, we can use a low-degree polynomial to model the data, i.e., weassume that the NO concentration can be approximated by

f(t) = x1tp + x2t

p−1 + . . .+ xpt+ xp+1,

where t is the time, p is the degree of the polynomial, and x1, x2, . . . xp+1 are the unknowncoefficients in the polynomial. A better model however, since the data repeats every daywould use periodic functions:

f(t) = x1 + x2 sin(ωt) + x3 cos(ωt) + x4 sin(2ωt) + x5 cos(2ωt) + . . .

where ω = 2π/24 is the period. Again, x1, x2, . . . are the unknown coefficients. Thegoal of data fitting is to estimate the coefficients x1, x2, . . ., so that we can evaluate thefunction f(t) for any argument t.

(a) Derive the least squares problem for both the polynomial fit with polynomial ofdegree p = 8 and the trigonometric fit with 9 functions. (Note: In both cases, thereare 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 poly-nomial least squares fit on the same graph and another that plots the data pointsalong with the trigonometric least squares fit on the same graph. Which approachis better and why?

2. Recall the example of image compression using the singular value decomposition thatwe saw in class. Now we want to compress a larger image.

Page 2: CMDA3606_HW2

(a) Load an image into Matlab (the image should be 256 × 256 or larger) and displaythe image in a figure. You can select from Matlab’s built in images, or pick anotherimage you like. If your image is in color, convert it to grayscale. What is the sizeand rank of your image? (Hint: Use rank(A) to determine the rank of a matrix inMatlab)

(b) Compute the SVD of A and plot the singular values of A. What do you noticeabout the decay of the singular values? Are there a few singular values that aremuch larger than the rest?

(c) Next we would like to compress this image with truncated singular value decompo-sitions. Compute compressions of your image using truncated SVDs Ak for variousvalues 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 MinionProitalic font, defined in the image files minionamp.jpg and minion11.jpg, each ofwhich leads to a 200 × 200 matrix. Which image do you think will better lenditself to low-rank approximation? Compute the singular values and truncated SVDapproximations 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 anampersand, which one can clearly see here derives from the Latin word et, meaning “and.”)

Page 2 of 2