Пример #1
0
 def distance_L2(d1, d2):  # deprecated
     """ Distance that does not take into account the uncertainty. """
     warnings.warn('deprected function, use Diffeo2Distance objects instead')
     assert isinstance(d1, Diffeomorphism2D)
     assert isinstance(d2, Diffeomorphism2D)
     from diffeo2d import diffeo_distance_L2
     return diffeo_distance_L2(d1.d, d2.d)
Пример #2
0
 def distance_L2(d1, d2):  # deprecated
     """ Distance that does not take into account the uncertainty. """
     warnings.warn(
         'deprected function, use Diffeo2Distance objects instead')
     assert isinstance(d1, Diffeomorphism2D)
     assert isinstance(d2, Diffeomorphism2D)
     from diffeo2d import diffeo_distance_L2
     return diffeo_distance_L2(d1.d, d2.d)
Пример #3
0
 def similarity(a1, a2):
     ''' Returns a similarity score between two actions
         1=same
         0=uncorrelated
         -1=inverse
     '''
     # These are distances, in [0, max]
     d_max = np.sqrt(2) / 2
     same_d = diffeo_distance_L2(a1.d, a2.d)
     oppo_d = 0.5 * (diffeo_distance_L2(a1.d, a2.d_inv) + 
                     diffeo_distance_L2(a2.d, a1.d_inv))
     # we have to normalize [0,max] -> [1,0]
     # we go through an "angle" representation
     same_d = same_d / d_max * (np.pi / 2)
     oppo_d = oppo_d / d_max * (np.pi / 2)
     if same_d < oppo_d:  # more similar than inverse
         return np.cos(same_d)
     else:
         return -np.cos(oppo_d)
Пример #4
0
 def distance_to_inverse(a1, a2):
     oppo_d = 0.5 * (diffeo_distance_L2(a1.d, a2.d_inv) + 
                     diffeo_distance_L2(a2.d, a1.d_inv))
     return oppo_d
Пример #5
0
 def distance(a1, a2):
     return diffeo_distance_L2(a1.d, a2.d)