(self, x)
| 48 | return other |
| 49 | |
| 50 | def push(self, x): |
| 51 | x = np.asarray(x) |
| 52 | # Unvectorized update of the running statistics. |
| 53 | if x.shape != self._M.shape: |
| 54 | raise ValueError( |
| 55 | "Unexpected input shape {}, expected {}, value = {}".format( |
| 56 | x.shape, self._M.shape, x)) |
| 57 | n1 = self._n |
| 58 | self._n += 1 |
| 59 | if self._n == 1: |
| 60 | self._M[...] = x |
| 61 | else: |
| 62 | delta = x - self._M |
| 63 | self._M[...] += delta / self._n |
| 64 | self._S[...] += delta * delta * n1 / self._n |
| 65 | |
| 66 | def update(self, other): |
| 67 | n1 = self._n |