Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. def cov_matrix(y1, y2):
  2. cov1 = np.cov(y1)
  3. cov2 = np.cov(y2)
  4.  
  5. [L1, U1] = np.linalg.eig(cov1)
  6. [L2, U2] = np.linalg.eig(cov2)
  7. U1 = U1.real
  8. U2 = U2.real
  9. L1 = L1.real
  10. L1 = L1.real
  11. L1 = np.diag(L1)
  12. L2 = np.diag(L2)
  13. R1 = np.dot(U1, L1)
  14. R1 = np.dot(R1, U1.T)
  15. R2 = np.dot(U2, L2)
  16. R2 = np.dot(R2, U2.T)
  17. return R1, R2
  18.  
  19. def PDF(x, u, R):
  20. [col] = u.shape
  21. a = np.power(2*np.pi, col)
  22. b = np.linalg.det(R)
  23. den = np.dot(a, b)
  24. den = np.sqrt(den, 2)
  25.  
  26. a = u - x
  27. b = np.power(R, -1)
  28. c = np.dot(a.T, b)
  29. esp = -np.dot(c, a)/2
  30.  
  31. F = (exp(esp))/den
  32.  
  33. return F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement