daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Apr 21st, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mean = [0,0]
  2. cov = [[50,20],[80,15]]
  3.  
  4. x1,x2 = np.random.multivariate_normal(mean,cov,100).T
  5.  
  6. X = np.c_[x1,x2]
  7.  
  8. plt.xlim(-30.0,30.0)
  9. plt.ylim(-30.0,30.0)
  10. plt.grid()
  11.  
  12. plt.scatter(X[:,0],X[:,1])
  13.  
  14.  
  15.  
  16.  
  17.  
  18. pca = PCA(n_components=1)
  19. pca.fit(X)
  20. axis /= axis.std()
  21.  
  22. axis = pca.components_.T
  23. axis /= axis.std()
  24.  
  25. x_axis, y_axis = axis
  26.  
  27. plt.quiver(0, 0, x_axis, y_axis, zorder=11,width=0.01,scale=6,  color='red')
  28.  
  29.  
  30. plt.savefig('pca')
  31. plt.show()
  32.    
  33. mean = [0,0]
  34. cov = [[50,20],[80,15]]
  35.  
  36. x1,x2 = np.random.multivariate_normal(mean,cov,100)
RAW Paste Data
Top