def memorize_chunk(self, x, center=True, rescale=True, ddof=0): x = atleast_2d_column_default(x) if self.current_mean is None: self.current_mean = np.zeros(x.shape[1], dtype=wide_dtype_for(x)) self.current_M2 = np.zeros(x.shape[1], dtype=wide_dtype_for(x)) # XX this can surely be vectorized but I am feeling lazy: for i in xrange(x.shape[0]): self.current_n += 1 delta = x[i, :] - self.current_mean self.current_mean += delta / self.current_n self.current_M2 += delta * (x[i, :] - self.current_mean)
def memorize_chunk(self, x): x = atleast_2d_column_default(x) self._count += x.shape[0] this_total = np.sum(x, 0, dtype=wide_dtype_for(x)) # This is to handle potentially multi-column x's: if self._sum is None: self._sum = this_total else: self._sum += this_total