Reference no: EM13923478
1. For a domain defined between -5 ≤ x ≤ 5 -5
- 5 ≤ y ≤ 5
0 ≤ t 10
Generate a dataset with variability in space and time following:
f (x, y, t) = f1 (x, y, t) + f2 (x, y, t) + f3 (x, y, t)
• Standing wave oscillating in time:
f1(x,y,t) = Sin(0.2Πy) * Cos(0.5Πx) * (1 + Cos(2Πt))
• Trend (increasing magnitude in time) with random component:
f2(x, y, t) = 0.09 * t + ε where ε = N(0, 0.01)
• Spike in space at different times:
-1 ≤ x ≤ 1 and
F3(x, y, t) = 0.8 if = -1 ≤ y ≤ 1 and
t = 0.4, 1 2, 2.5, 3, 4 2,5,5.3, 6.2,6.6, 7.5,9
= 0 Otherwise
This problem is aimed at helping you understand the PCA method using an idealized dataset Since you know the data you are generating it should help you understand the capability of the method.
a. Perform a principal component analysis on the dataset you have generated.
b. What is the total variability in the dataset?
c. What is the percent of the total variability explained by the first three components?
d. How many components should be retained?
e. Plot the spatial representation of each of the PCs you retained.
f. Reconstruct (back transform] your original data after reducing the dimensionality of the data. Plot the scores of each of the PCs you retained
Discuss your results.
2. Using a precipitation dataset provided to you (angle \ homework\ PIV.txt), perform a PCA analysis and interpret the results. Answer the same questions as in Problem 1 The file P_124 file contains monthly precipitation in U.S. from
• January 1979 - December 2000 (264 months).
• It extends from 140 W to 60 W (33 longitude points or rows) and
• 20 N to 60 N (17 latitude points or columns)
It covers the conterminous -United States. The file is read first by longitude, then by latitude and then by time.
When you are doing the PCA, remove the means for each month.
For example: Jani; - average(Jan(1979 - 2001)), so that the dominant mode will not capture the intra-annual cycle (not very interesting).
In case if it helps, I have converted the original precipitation data (PW.txt) to Locations - by - Time 2D data (PW_Loc_Time.txt) and added the file in the homework folder. You can use this new file to calculate the covariance and the PCAs. The figure below shows the spatial variation of the precipitation for month (T = 20). In general, the data consist of 264 (total number of months) similar spatial variations.
Matlab code for reshaping the file:
% Import data
load PW.txt -ASCII
% data size (known)
rows = 33; cols = 17; locat = rows*cols;
months = 264;
%Reshape my data
PWin = reshape(PW,locat,months);
[X,Y] = meshgrid((l:rows),(1:cols));
% which month do you want to plot?
mnt = 20;
Z = reshape(PWin(:,mnt),rows,cols);