Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import numpy as np
  2.  
  3.  
  4. X_1 = np.array([1, 1])
  5. X_2 = np.array([2, 3])
  6.  
  7. def get_X_median(list_X):
  8.     return np.mean(list_X, axis=0)
  9.  
  10. X_mediana = get_X_median([X_1, X_2])
  11.  
  12.  
  13. def get_S(list_x):
  14.     X_median = np.mean(list_x, axis=0)
  15.     ans = np.zeros(shape=(len(list_x), len(list_x)))
  16.     for ele in list_x:
  17.         M = np.array(ele - X_median).reshape(-1,1)
  18.         ans += M.dot(M.T)
  19.     return ans / (len(list_x) - 1)
  20.  
  21. print(get_S([X_1, X_2]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement