<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Kerrie,<br>
<br>
They should be different by a factor of 1/(n-1), since eofunc is
computing the covariance matrix itself. In your case, that factor is
exactly 1/3.<br>
<br>
best wishes,<br>
<br>
gil<br>
<br>
<br>
<br>
On 11/29/11 2:14 PM, Kerrie Geil wrote:
<blockquote
cite="mid:CAKBe+-ARF8sVMzHmmQM=R_wTWhgGAwgZj57H98FW_RN+3qsSfw@mail.gmail.com"
type="cite">Hi All,<br>
<br>
Can anyone tell me why the singular value decomposition
(svd_lapack) below yields different eigenvalues than the
eigenanalysis (eofunc, eofunc_ts), while both output the exact
same EOFs and PCs? Can't see what I'm doing wrong. Code and
output are below.<br>
<br>
Thanks!<br>
Kerrie<br>
<br>
<br>
;######################################################################################<br>
;### data array A=(/ntime,nspace/) ###<br>
A=(/ (/-2.,1./),(/7.,-8./),(/-3.,0./),(/5.,-9./) /)<br>
A!0="time"<br>
A!1="space"<br>
ntime=4 ;### number of rows, time dimension 0 ###<br>
nspace=2 ;### number of columns, space dimension 1 ###<br>
<br>
Aprime = dim_rmvmean_n(A,0)<br>
;### singular value decomposition of Aprime ### <br>
;### Aprime=(u)(s)(vtranspose)-----> (4x2)=(4x2)(2x2)(2x2)
###<br>
u = new ( (/ntime,nspace/) , float ) ;###
columns of u are PC eigenvectors ###<br>
vtranspose = new ( (/nspace,nspace/) , float
) ;### rows of vtranspose are EOF eigenvectors
###<br>
s = svd_lapack (Aprime, "S" , "S", 0, vtranspose, u)
;### s^2=eigenvalues<br>
;### s is returned with only the non-zero (diagonal) values<br>
<br>
print("for SVD")<br>
print("U:")<br>
write_matrix (u, "2f10.4", False)<br>
print("V:")<br>
write_matrix (vtranspose, "2f10.4", False)<br>
print("lambda:")<br>
print(s^2)<br>
<br>
<br>
At=transpose(A) ;### make time the rightmost dimension
###<br>
eof=eofunc(At,2,False) ;### rows of eof are EOFs ###<br>
eoftranspose=transpose(eof)<br>
pc=eofunc_ts_Wrap(At,eof,False) ;### rows of pc are PCs
###<br>
pctranspose=transpose(pc) ;### for similarity to SVD
matrices, now columns of pc are PCs ###<br>
pc_colsum=dim_sum_n(pctranspose^2,0) ;### square each
component and sum the columns ###<br>
pctranspose(:,0)=pctranspose(:,0)/sqrt(pc_colsum(0))
;### normalize PC1<br>
pctranspose(:,1)=pctranspose(:,1)/sqrt(pc_colsum(1))
;### normalize PC2<br>
<br>
print("for eofunc")<br>
print("U:")<br>
write_matrix (pctranspose, "2f10.4", False)<br>
print("V:")<br>
write_matrix (eof, "2f10.4", False)<br>
print("lambda:")<br>
print(eof@eval)<br>
;######################################################################################<br>
<br>
<br>
OUPUT IS:<br>
<br>
<span style="color: rgb(51, 51, 255);">(0) for SVD</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) U:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.5010 0.4050</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.5261 0.5745</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.4983 -0.3748</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.4732 -0.6046</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) V:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.6898 0.7240</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.7240 0.6898</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) lambda:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) 153.4626</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(1) 3.287447</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) </span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) </span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) for eofunc</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) U:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.5010 0.4050</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.5261 0.5745</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.4983 -0.3748</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.4732 -0.6046</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) V:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> -0.6898 0.7240</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> 0.7240 0.6898</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);"> </span><br style="color:
rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) lambda:</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(0) 51.15419</span><br
style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">(1) 1.095816</span><br>
<br>
<br>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
+++++++++++++++++++++++++++++++++++++++++++++++++++
Gil Compo, Research Scientist, CIRES
University of Colorado
Mail : CIRES Climate Diagnostics Center
NOAA Physical Sciences Division
Earth System Research Laboratory
325 Broadway R/PSD1, Boulder, CO 80305-3328
Email: <a class="moz-txt-link-abbreviated" href="mailto:compo@colorado.edu">compo@colorado.edu</a>
Phone: (303) 497-6115 Fax: (303) 497-6449
<a class="moz-txt-link-freetext" href="http://www.esrl.noaa.gov/psd/people/gilbert.p.compo">http://www.esrl.noaa.gov/psd/people/gilbert.p.compo</a>
+++++++++++++++++++++++++++++++++++++++++++++++++++
"Stop and consider the wondrous works of God."
Job 37:34
---------------------------------------------------
The contents of this message are mine personally
and do not necessarily reflect any position of
NOAA or the University of Colorado.
</pre>
</body>
</html>