代写CMDA 3605 : Fall 2018 : Homework 3 程序作业、代写MATLAT 程序作业、代写R编程作业、代写SPSS,STAT作业代写留学生

代写CMDA 3605 : Fall 2018 : Homework 3 程序作业、代写MATLAT 程序作业、代写R编程作业、代写SPSS,STAT作业代写留学生
CMDA 3605 : Fall 2018 : Homework 3
Due : Saturday September 22 by 11:59 pm : Submitted online in Canvas
Late Policy: Each student can submit up to two homework assignments late without penalty. If you choose
to submit this assignment late it must be submitted online in Canvas by Sunday September 23 by 11:59 pm.
To receive credit you must show all work (don’t just give the answers)!
1. (Matlab) Download the file power1.m from Canvas. In this exercise you will use the power1 Matlab
function from class to implement the function powerk. The purpose of powerk is to use deflation
combined with the power method to calculate the k largest eigenvalues with corresponding unit length
eigenvectors. See problem 3 from in-class assignment 3 for details on the deflation method to use for
this exercise. Note that this function will only work if AT = A!
(a) Here is a template for the powerk function to get you started. Remember that your powerk function
must go into its own file with powerk.m as the filename.
% Returns the k largest eigenvalues in the array lambdas
% with corresponding with unit length eigenvectors in the matrix U
% The number of iterations required for each eigenvalue is stored
% in the array nums.
% This function Only works if A?T = A.
function [U,lambdas,nums] = powerk (A,eps,k)
U = zeros (size(A,2),k);
lambdas = zeros (1,k);
nums = zeros (1,k);
for (i=1:k)
% Add your code here!
end
(b) As a first test of your powerk function, execute the following Matlab code.
A = [2,1,1,1;1,2,1,1;1,1,2,1;1,1,1,2];
[U,lambdas,num] = powerk(A,1e-6,4)
eigs(A)
U'*U
U*diag(lambdas)*U'
Verify that your eigenvalues agree with those calculated by Matlab. Note that the powerk function
works properly even in the case where A has repeated eigenvalues! The second to last line of code
verifies that U
TU = I and thus U is an orthogonal matrix and the eigenvectors you found form an
orthonormal basis for R
4
. The last line of code verifies that
A = UDUT
where D is a diagonal matrix with the eigenvalues of A on the main diagonal. Thus, you have
calculated an orthogonal diagonalization of A!
1
(c) Next we will do a bigger test of your function powerk. Download the file hw3.mat from Canvas.
The file hw3.mat contains a matrix A in R
6×36 that stores movie review data from 36 movie viewers
who gave each of 6 movies an integer rating from 1 to 5. Run the following code which uses the
technique of dimension reduction on the data so that we can visualize it in 2 dimensions and look
for patterns.
% Load in the moview review matrix
load('hw3.mat','A');
[m,n] = size(A);
% Calculate the sample mean
sum1 = A(:,1);
for (i=2:n)
sum1 = sum1 + A(:,i);
end
mean = (1/n)*sum1;
% subtract sample mean from each column of A
for (i=1:n)
M(:,i) = mean;
end;
B = A - M;
% Find the first two dominant eigenvalues and corresponding
% eigenvectors for the matrix BB?T
[U,lambdas,nums] = powerk(B*B',1e-6,2);
% Plot the reduced dimensional data
C = U'*B;
plot (C(1,:),C(2,:),'o','MarkerSize',6,'Color','black');
title ('Data Plot after Dimension Reduction');
What do you observe? Can you explain the clusters?
2. (Matlab) If you have not already, download the file hw3.mat from Canvas. Use the following code to
read the movie review data into the matrix A.
% Load in the moview review matrix
load('hw3.mat','A');
If you have not already, download the file power1.m from Canvas.
(a) Use the function power1 to calculate kAk and a unit vector u
?
such that kAu
?k = kAk.
(b) Verify that your choice of u
? works by using Matlab to calculate kAu
?k.
2
3. Deep in the forests, dusky-footed wood rats provide up to 80% of the diet for the spotted own, the main
predator of the wood rat. Denote the owl and wood rat population at time k by
pk =
"
ok
rk
#
and assume that
pk+1 =
"
0.5 0.4
?0.104 1.1
#
pk
(a) The eigenvalues of A are λ1 = 1.02 and λ2 = 0.58. Find corresponding eigenvectors v1 and v2.
(b) Suppose p0 =
"
5
12#
. Suppose we write the vector p0 as a linear combination of the eigenvectors
p0 = c1v1 + c2v2
Find c1 and c2.
(c) Recall in class we showed that
pk = A
kp0 = c1λ
k
1v1 + c2λ
k
2v2
Find a simple big k approximation of pk as we did in class.
(d) Use your big k approximation to calculate lim
k→∞
pk
kpkk∞
= lim
k→∞
Akp0
kAkp0k∞
.
(e) Calculate the eventual growth rate of the combined population of owls and rats.
(f) Calculate the eventual ratio of owls to rats.
4. Let A ∈ R
n×n such that AT = A. In this exercise, you will show that any two eigenvectors corresponding
to distinct eigenvalues of A are orthogonal.
Step 1: Suppose that Au1 = λ1u1, Au2 = λ2u2, and λ1 6= λ2. Show that
λ1(u1 · u2) = λ2(u1 · u2) (1)
Here is a start
λ1(u1 · u2) = (λ1u1) · u2 = (λ1u1)
Tu2 = (Au1)
Tu2 =
Step 2: Since λ1 6= λ2, conclude from equation (1) that u1 · u2 = 0.
5. Let A =
"
2 ?1
2 2 #
.
(a) Calculate kAk.
(b) Find a unit vector u
?
such that kAu
?k = kAk.
(c) Verify that your choice of u
? works by calculating kAu
?k.
Note: In this exercise, you can use Matlab to verify your answers but you have to show the necessary
steps carried out by hand.
6. Let A ∈ R
m×n and let α > 0 be a real number. Show that AT A + αI is invertible.
Hint: Show that the eigenvalues of AT A + αI are all positive.
http://www.daixie0.com/contents/13/1714.html

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/javahelp89/p/9690924.html