Commits

Sean Cassidy committed e3b53a6

Use correct terminology

Comments (0)

Files changed (2)

 
 ## Example usage
 
-When constructing a LiveStats object, pass in an array of the percentiles you wish you track. LiveStats stores 15 double values per percentile supplied.
+When constructing a LiveStats object, pass in an array of the quantiles you wish you track. LiveStats stores 15 double values per quantile supplied.
 
     from livestats import LiveStats
     from math import sqrt
         for y in xrange(100):
             test.add(data.next()*100)
 
-        print "Average {}, stddev {}, percentiles {}".format(test.mean(), 
-                sqrt(test.variance()), test.percentiles())
+        print "Average {}, stddev {}, quantiles {}".format(test.mean(), 
+                sqrt(test.variance()), test.quantiles())
 
 Easy.
 
 ## How accurate is it?
 
-Very accurate. If you run livestats.py as a script with a numeric argument, it'll run some tests with that many data points. As soon as you start to get over 10,000 elements, accuracy to the actual percentiles is well below 1%. At 10,000,000, it's this:
+Very accurate. If you run livestats.py as a script with a numeric argument, it'll run some tests with that many data points. As soon as you start to get over 10,000 elements, accuracy to the actual quantiles is well below 1%. At 10,000,000, it's this:
 
     Uniform:    Avg%E 1.732260e-12 Var%E 2.999999e-05 Perc%E 1.315983e-05
     Expovar:    Avg%E 9.999994e-06 Var%E 1.000523e-05 Perc%E 1.741774e-05
     Triangular: Avg%E 9.988727e-06 Var%E 4.839340e-12 Perc%E 0.015595
     Bimodal:    Avg%E 9.999991e-06 Var%E 4.555303e-05 Perc%E 9.047849e-06
 
-That's percent error for the cumulative moving average, variance, and the average percent error for four different random distributions at three percentiles, 25th, 50th, and 75th. Pretty good.
+That's percent error for the cumulative moving average, variance, and the average percent error for four different random distributions at three quantiules, 25th, 50th, and 75th. Pretty good.
 
 # More details
 
 
     return q + outer * (inner_left + inner_right)
 
-class Percentile:
+class Quantile:
     LEN = 5
     def __init__(self, p):
-        """ Constructs a single Percentile object """
+        """ Constructs a single quantile object """
         self.dn = [0, p/2, p, (1 + p)/2, 1]
         self.npos = [1, 1 + 2*p, 1 + 4*p, 3 + 2*p, 5]
         self.pos = range(1, self.LEN + 1)
 
                 self.pos[i] = n + d
 
-    def percentile(self):
+    def quantile(self):
         if self.initialized:
             return self.heights[2]
         else:
 
         Keyword arguments:
 
-        p -- A list of percentiles to track, by default, [0.5]
+        p -- A list of quantiles to track, by default, [0.5]
 
         """
         self.var_m2 = 0.0
         self.tiles = {}
         self.initialized = False
         for i in p:
-            self.tiles[i] = Percentile(i)
+            self.tiles[i] = Quantile(i)
 
     def add(self, item):
         """ Adds another datum """
         self.skew_m3 = self.skew_m3 + (item - self.average)**3.0
 
 
-    def percentiles(self):
-        """ Returns a list of tuples of the percentile and its location """
-        return [(key, val.percentile()) for key, val in self.tiles.iteritems()]
+    def quantiles(self):
+        """ Returns a list of tuples of the quantile and its location """
+        return [(key, val.quantile()) for key, val in self.tiles.iteritems()]
 
     def mean(self):
         """ Returns the cumulative moving average of the data """
 
 def output (tiles, data, stats, name):
     data.sort()
-    tuples = [x[1] for x in stats.percentiles()]
+    tuples = [x[1] for x in stats.quantiles()]
     med = [data[int(len(data) * x)] for x in tiles]
     pe = 0
     for approx, exact in zip(tuples, med):