from numpy import * import numpy as np from numpy import linalg as LA #Numerically verify these results by drawing a data set from the distribution #and computing the covariance matrix and eigenvalues. x = empty((3,3)) #create random matrix 3x3 a = x[:,0] #extract column 0 b = x[:,1] #extract colum 1 c = a + b d = x[:,2] c = d #Place "c" in column 2 print x #Calculate covariance of x: covx = np.cov(x) print covx #Calculate eigenvalues of x: w,v = LA.eig(x) print w;v #Calculate eigenvalues of covariance of x: e,f = LA.eig(covx) print e;f #################################################### #pts = 1000 #x1 = np.random.random(pts) #x2 = random.random(pts) #x3 = x1 + x2 #covx = np.cov(x) #print covx #####WORKS #x = array([[1,0,1],[0,1,1],[1,1,2]]) #Calculate eigenvalues: #w,v = LA.eig(x) #print w;v #Calculate the Covariance: #print np.cov(w,v)