Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. p(XY) = 0.5 * P(X = Y) + 1 * P(X > Y)
  2.  
  3. import numpy as np
  4. x = [-0.01, -0.05, -0.13, -0.02, -0.17, -0.09, 0.0, -0.04, -0.03, 0.06, -1.37, -0.03, 0.01, -0.57, 0.04, -0.09, -0.04, -5.56, -0.02, 0.0, 0.0, 0.0, 0.0, -0.03, -0.55, -2.6, -0.42, -1.35, 0.0, 0.43, -0.74, -0.47, 0.0, -20.25, -11.18, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  5.  
  6. y = [0.0, -0.16, -0.11, -0.04, -0.1, 0.02, -0.04, -0.13, -0.03, -0.04, 0.0, -0.01, 0.01, -0.38, 0.13, -0.26, -0.11, -0.09, 0.0, 0.0, 0.18, 0.0, -0.02, 0.03, -0.17, 0.21, 0.17, -0.42, 0.0, 0.87, 0.15, 0.0, 0.47, 3.73, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  7. bins = np.arange(min(x + y), max(x + y), 0.01)
  8.  
  9. # x histogram (normalized to sum 1.0)
  10. hx, dx = np.histogram(x, bins)
  11. hx = 1.0*hx/np.sum(hx) # max(hx) = 0.3170731707317073
  12.  
  13. # y histogram (normalized to sum 1.0)
  14. hy, dy = np.histogram(y, bins)
  15. hy = 1.0*hy/np.sum(hy) # max(hy) = 0.34999999999999998
  16.  
  17. # Now comes the hard part, the result doesn't match with the paper (0.345)
  18. # this gives 1.03597561
  19. np.correlate(hx, hy)*0.5 + sum(np.correlate(hx, hy, 'same'))
  20.  
  21. # this gives 1.06097561
  22. np.correlate(hx, hy)*0.5 + sum(np.correlate(hx, hy, 'full'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement