Commits

committed 993a298

Minimum and maximum data points

• Participants
• Parent commits 55a2541

Files changed (2)

` `
` Easy.`
` `
`+There are plenty of other methods too, such as minimum, maximum, [kurtosis](http://en.wikipedia.org/wiki/Kurtosis), and [skewness](http://en.wikipedia.org/wiki/Skewness).`
`+`
` # FAQ`
` `
` ## How does this work? `

File livestats.py

`         p -- A list of quantiles to track, by default, [0.5]`
` `
`         """`
`+        self.min_val = float('inf')`
`+        self.max_val = float('-inf')`
`         self.var_m2 = 0.0`
`         self.kurt_m4 = 0.0`
`         self.skew_m3 = 0.0`
`         """ Adds another datum """`
`         delta = item - self.average`
` `
`+        self.min_val = min(self.min_val, item)`
`+        self.max_val = max(self.max_val, item)`
`+`
`         # Average`
`         self.average = (self.count * self.average + item) / (self.count + 1)`
`         self.count = self.count + 1`
`         """ Returns a list of tuples of the quantile and its location """`
`         return [(key, val.quantile()) for key, val in self.tiles.items()]`
` `
`+    def maximum(self):`
`+        """ Returns the maximum value given """`
`+        return self.max_val`
`+`
`     def mean(self):`
`         """ Returns the cumulative moving average of the data """`
`         return self.average`
` `
`+    def minimum(self):`
`+        """ Returns the minimum value given """`
`+        return self.min_val`
`+`
`     def num(self):`
`         """ Returns the number of items added so far"""`
`         return self.count`