Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import numpy as np
  2. import math
  3.  
  4. def geo_mean(iterable):
  5. a = np.array(iterable)
  6. return a.prod()**(1.0/len(a))
  7.  
  8. def get_vector(A):
  9. W = []
  10. norm = 0
  11. for i in range(A[0].size):
  12. W.append(geo_mean(A[i]))
  13. norm += W[i]
  14. return W/norm
  15.  
  16. def max_eigen_value(A):
  17. return np.linalg.eig(A)[0].real.max()
  18.  
  19. def Satty(A):
  20. return ((max_eigen_value(A)-len(A))/(len(A)-1))
  21.  
  22. def Geometryczny(A):
  23. ranking = get_vector(A)
  24. for i in range (0,A.size):
  25. for j in range (i+1,A.size):
  26. math.log(A[i][j] * )**2
  27.  
  28.  
  29.  
  30. A = np.array([
  31. [1, 7, 3],
  32. [1/7, 1, 2],
  33. [1/3, 1/2, 1]])
  34.  
  35. B = np.array([
  36. [1, 1/5, 7,1],
  37. [5, 1, 1/2,2],
  38. [1/7, 2, 1,3],
  39. [1,1/2,1/3,1]])
  40.  
  41. C = np.array([
  42. [1, 2, 5, 1, 7],
  43. [1/2, 1, 3, 1/2, 5],
  44. [1/5, 1/3, 1, 1/5, 2],
  45. [1, 2, 5, 1, 7],
  46. [1/7, 1/5, 1/2, 1/7, 1]])
  47.  
  48.  
  49. SattyA = Satty(A)
  50. SattyB = Satty(B)
  51. SattyC = Satty(C)
  52.  
  53. GeoA = Geometryczny(A)
  54.  
  55. print(SattyA)
  56. print(SattyB)
  57. print(SattyC)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement