Coverage for python/lsst/sims/maf/metrics/kuiperMetrics.py : 42%

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
4__all__ = ['KuiperMetric']
7class KuiperMetric(BaseMetric):
8 """Find the Kuiper V statistic for a distribution, useful for angles.
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])
18 dist_1 = (np.arange(values.size)+1)/values.size
19 uniform = values/(360.)
21 d_plus = np.max(uniform - dist_1)
22 d_minus = np.max(dist_1-uniform)
23 result = d_plus + d_minus
25 return result