Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import numpy as np 

2from .baseMetric import BaseMetric 

3 

4__all__ = ['KuiperMetric'] 

5 

6 

7class KuiperMetric(BaseMetric): 

8 """Find the Kuiper V statistic for a distribution, useful for angles. 

9 

10 Value of 0 means perfecty uniform, 1 means delta function 

11 """ 

12 def run(self, dataSlice, slicePoint=None): 

13 """ 

14 """ 

15 # Assume input in degrees 

16 values = np.sort(dataSlice[self.colname]) 

17 

18 dist_1 = (np.arange(values.size)+1)/values.size 

19 uniform = values/(360.) 

20 

21 d_plus = np.max(uniform - dist_1) 

22 d_minus = np.max(dist_1-uniform) 

23 result = d_plus + d_minus 

24 

25 return result