Advertisement
cyphric

Untitled

Apr 28th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. from cmath import sqrt
  2. import numpy as np
  3. from matplotlib import pyplot as plt
  4. from scipy.spatial import distance
  5. from scipy.stats import multivariate_normal
  6.  
  7. def prob(x_curr, y_curr, base_positions, noise):
  8. v = 90
  9. eta = 3
  10. car_pos = np.vstack((x_curr, y_curr))
  11. euc_distance = np.linalg.norm(car_pos - base_positions)
  12. Y = v - 10*eta*np.log10(euc_distance)+noise
  13. mean_y = 90 - 10*eta*np.log10(euc_distance)
  14.  
  15. p = multivariate_normal.pdf(Y, mean=mean_y, cov=0.5)
  16. return p
  17.  
  18.  
  19. def grid_plot(x_size, y_size, base_positions):
  20. x = np.arange(-x_size, x_size)
  21. y = np.arange(-y_size, y_size)
  22. plt.title("Base positions of towers")
  23. plt.xlabel("X-positions")
  24. plt.ylabel("Y-positions")
  25. plt.plot(base_positions[0],base_positions[1],"o")
  26. plt.show()
  27.  
  28. def main():
  29. positions = np.array([[0, 0, 3464.1, 3464.1, -3464.1, -3464.1],[4000,-4000,2000,-2000,-2000,2000]], np.float16)
  30. x_0 = np.random.multivariate_normal(np.zeros(6), np.diag((500,5,5,500,5,5))).reshape(6,1)
  31. noise = np.random.normal(0,1.5,x_0.size)
  32. for i in range(0,x_0.size):
  33. print(prob(x_0[0],x_0[4],positions[:,i],noise[i]))
  34. #grid_plot(5000,5000,positions)
  35.  
  36.  
  37.  
  38.  
  39.  
  40. if __name__ == "__main__":
  41. main()
  42.  
  43.  
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement