Guest User

Haar measure on SO(n)

a guest
Apr 3rd, 2024
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import numpy as np
  2. import numpy.linalg as la
  3. import scipy.stats as ss
  4. import matplotlib.pyplot as plt
  5.  
  6.  
  7. d = 20 # dimesion of matrices
  8. n = 1000 # number of matrices
  9. h = 500 # number of Histogram bins for plotting only
  10.  
  11.  
  12. evals = np.zeros((d,n))
  13. # seps = np.zeros((d-1,n))
  14. for i in range(n):
  15. # a = ss.special_ortho_group.rvs(d)
  16. tmp = np.random.randn(d,d)
  17. q, r = la.qr(tmp)
  18. a = q @ np.diag(np.sign(np.diag(r)))
  19. # a[:,0] = a[:,0] * np.sign(la.det(a)) # (un)comment this line to toggle between SO(n) and O(n)
  20. # Haar measure:
  21. b,_ = la.eig(a)
  22. evals[:,i] = np.sort(np.angle(b))
  23.  
  24.  
  25. # %%
  26. seps = np.diff(evals,axis=0)*d/(2*np.pi)
  27.  
  28. plt.hist(evals.flatten(), bins=h)
  29. plt.title(f'Dimension: {d}, Number: {n}, HistogramBins: {h}')
  30. plt.show()
  31.  
  32.  
  33. plt.hist(seps.flatten(), bins=h)
  34. plt.title(f'Dimension: {d}, Number: {n}, HistogramBins: {h}')
  35. plt.show()
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment