News for hackers. Stuff that matters.
Re:Universal Method to Sort Complex Information Found by tlb on Tuesday August 14, 2018 @12:26PM (#17759320)
Ah, I mistook the - at the beginning for a separator.

It does fail the triangle inequality, though, as the following python snippit demonstrates:

  import numpy as np

  def randomvec():
      return np.random.rand(4)*2-1

  def cossim(a, b):
      return np.dot(a,b) / np.sqrt(np.dot(a, a) * np.dot(b, b))

  def metric(a, b):
      return -np.log((1+cossim(a, b))/2)

  def main():
      for i in range(20):
          a = randomvec()
          b = randomvec()
          c = randomvec()
          a2b = metric(a, b)
          b2c = metric(b, c)
          a2c = metric(a, c)
          print a2b, b2c, a2c
          if a2b + b2c < a2c:
              print '  *** fails triangle inequality'
   
  main()
Re:Universal Method to Sort Complex Information Found by DoctorOetker on Tuesday August 14, 2018 @03:05PM (#17760900)
good catch! upvoted