StatRed: finished multivariate (question 21).

parent c35ec4b5
from pylab import array, eig, diagflat, dot, sqrt, randn, tile
from pylab import plot, axis, show, figure, clf
from pylab import array, eig, diagflat, dot, sqrt, randn, tile, \
plot, subplot, axis, show, figure, clf
mean = array([[3],
[4],
......@@ -15,7 +15,7 @@ cov = array(
samples = 1000
vector_size = 4
figure(1)
figure(16)
clf()
d, U = eig(cov)
......@@ -24,21 +24,11 @@ A = dot(U, sqrt(L))
X = randn(vector_size, samples)
Y = dot(A,X) + tile(mean, samples)
#import matplotlib.pyplot as plt
for i in range(4):
for j in range(4):
for i in range(1, 5):
for j in range(1, 5):
if i != j:
plot(Y[i], Y[j], 'x')
subplot(4, 4, i+(j-1)*4)
plot(Y[i-1], Y[j-1], 'x')
axis('equal')
axis('equal')
#plt.plot(x,y,'x');
#plt.axis('equal');
#plt.show()
show()
#import numpy as np
#x,y = np.random.multivariate_normal(mean, cov, 5000).T
#print 'x:', x
#print 'y:', y
#plt.plot(x,y,'x'); plt.axis('equal'); plt.show()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment