Lab 9
In this lab we will explore using the SVD to analyze time series
Contents
Exercise 1: Plotting time series
Download the function
generateData(m)
from the course webpage. This function generates an matrix that represents the evolution of quantities over the course of 250 days (think stocks, if you're in to that kind of thing, or temperatures if you'd rather think about climate change).
The code
figure(1); A = generateData(10); plot(A); ylim([-10 10]);
will plot the trajectories of the quantities with a fixed y-axis range.
Exercise 2: Using MATLAB®'s SVD
Next, perform a singular value decomposition of the data
[U,S,V] = svd(A); % A = U*S*V'
Test the decomposition.
Exercise 3: Isolating trajectories
Use the code
figure(1); A = generateData(10); plot(A(:,1:2)); ylim([-10 10]);
to plot the time series for the first two quantities. Intuitively, it is clear that if one goes up, the other goes down, but is this a cause and effect relationship? Or is it just coincidental?
Perform
norm(A(:,1) + A(:,2))
to see that one trajectory is not just the negative of the other.
Exercise 4: Showing dependency
Using the SVD, zero out all but the first singular value: Construct a matrix where is obtained from by zero-ing out all entries except the entry. Plot the time series :
figure(2); plot(B); ylim([-10 10]);
and then consider
norm(B(:,1) + B(:,2))
What do you notice?