def meanAndStdDev(self, limit=None):
        """return the mean and the standard deviation optionally limited to the last limit values"""
        if limit is None or len(self.values) < limit:
            limit = len(self.values)
        if limit > 0:
            mean = sum(self.values[-limit:]) / float(limit)
            sumSq = 0.
            for v in self.values[-limit:]:
                sumSq += (v - mean) * (v - mean)
            return mean, math.sqrt(sumSq / limit)
        else:
            return None
def meanAndStdDev ( self , limit = None ) : if limit is None or len ( self . values ) < limit : limit = len ( self . values ) if limit > 0 : mean = sum ( self . values [ - limit : ] ) / float ( limit ) sumSq = 0. for v in self . values [ - limit : ] : sumSq += ( v - mean ) * ( v - mean ) return mean , math . sqrt ( sumSq / limit ) else : return None
return the mean and the standard deviation optionally limited to the last limit values