code: private Double scale(Double value, Double mean, Double std) {
          if(std.equals(0.0)) {
              if(value > mean) {
                  return 1.0;
              }
              else if(value < mean) {
                  return -1.0;
              }
              else {
                  return Math.signum(value);
              }
          }
          else {
              return (value-mean)/std;
          }
      }
docs: Performs the actual rescaling handling corner cases.
  
  @param value
  @param mean
  @param std
  @return