Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. obs1 = np.random.rand(1 ,200) #Generujesz 200-wymiarową losową wartość
  2. obs2 = np.random.rand(1, 200)
  3.  
  4.  
  5. dimenstions = range(2, 200)
  6. distances = []
  7. for index in dimenstions:
  8.    
  9.     elems = [obs1[0][:index + 1], obs2[0][:index + 1]] #bierzesz tylko pierwsze "index" wymiarów
  10.    
  11.     distances.append(np.linalg.norm(elems, 2))
  12.  
  13.  
  14. fig, ax = plt.subplots()
  15. ax.plot(dimenstions, distances)
  16.  
  17. ax.set(xlabel='dimension', ylabel='distance')
  18. ax.grid()
  19.  
  20. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement