text: import csv
  import glob
  import os
  import shutil
  
  import numpy as np
  
  
  class Scaler(object):
  
      def __init__(self, obs_dim):
          self.vars = np.zeros(obs_dim)
          self.means = np.zeros(obs_dim)
          self.m = 0
          self.n = 0
          self.first_pass = True
  
      def update(self, x):
          if self.first_pass:
              self.means = np.mean(x, axis=0)
              self.vars = np.var(x, axis=0)
              self.m = x.shape[0]
              self.first_pass = False
          else:
              n = x.shape[0]
              new_data_var = np.var(x, axis=0)
              new_data_mean = np.mean(x, axis=0)
              new_data_mean_sq = np.square(new_data_mean)
              new_means = ((self.means * self.m) +
                           (new_data_mean * n)) / (self.m + n)
              self.vars = (((self.m * (self.vars + np.square(self.means))) +
                            (n * (new_data_var + new_data_mean_sq))) / (self.m + n) -
                           np.square(new_means))
              self.vars = np.maximum(0.0, self.vars)
              self.means = new_means
              self.m += n
  
      def get(self):
          return 1/(np.sqrt(self.vars) + 0.1)/3, self.means
  