Commits

dan mackinlay committed 25b9963

try angles all positive to ease calculations

Comments (0)

Files changed (1)

     return binned.astype(np.int16)-1
 
 def bin_angle_naive(a, n_bins):
-    return bin_naive(a, n_bins, range=(-sp.pi, sp.pi))
+    return bin_naive(a, n_bins, range=(0.pi, 2*sp.pi))
 
 def choose_n_bins(n_data_points, test=True):
     """according to Cellucci et al (2005), the maximal number of bins is given
 
 def angle(x,y):
     """trivial helper for wicks MI calculations - gives the angle of a 2d
-    vector
+    vector, wrapped into [0, 2pi).
 
     >>> angle([1,1,0,-1,-1], [0,1,1,1,0])
-    array([ 1.57079633,  0.78539816,  0., -0.78539816, -1.57079633])
+    array([ 1.57079633,  0.78539816,  0.,  5.49778714,  4.71238898])
     """
-    return np.arctan2(x,y)
+    return (np.arctan2(x,y) + 2*np.pi) % (2*np.pi)
 
 def ince_mi_dist_cont(X, Y, n_bins=None, **kwargs):
     """wraps pyentropy's grandiose object initialisation and quantisation
     
     if no n_bins is given, we choose the maximimum statistically valid number
     by the cochrane criterion, and leave it be. This will give good results in
-    all except particularly pathological cases. (bins will be approximately equal occupancy)
+    all except particularly pathological cases. (bins will be approximately
+    equal occupancy)
     """
     kwargs.setdefault('method', 'qe')
     kwargs.setdefault('sampling', 'kt')