Performs the actual rescaling handling corner cases.

@param value
@param mean
@param std
@return
352630
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;
        }
    }
1024479
private static void scale(double constant, double vector[]) {
        if (constant == 1.0) return;
        for (int i = 0; i < vector.length; i++) {
            vector[i] *= constant;
        }

    }
283850
def normalize_std_array(vector):
  """"""

  # Initializes variables
  length = 1
  n_samples = len(vector)
  mean = numpy.ndarray((length,), 'float64')
  std = numpy.ndarray((length,), 'float64')
  mean.fill(0)
  std.fill(0)

  # Computes mean and variance
  for array in vector:
    x = array.astype('float64')
    mean += x
    std += (x ** 2)

  mean /= n_samples
  std /= n_samples
  std -= (mean ** 2)
  std = std ** 0.5
  arrayset = numpy.ndarray(shape=(n_samples,mean.shape[0]), dtype=numpy.float64)

  for i in range (0, n_samples):
    arrayset[i,:] = (vector[i]-mean) / std
  return arrayset
267470
private Double scale(Double value, Double min, Double max) {
        if(min.equals(max)) {
            if(value>max) {
                return 1.0;
            }
            else if(value==max && value!=0.0) {
                return 1.0;
            }
            else {
                return 0.0;
            }
        }
        else {
            return (value-min)/(max-min);
        }
    }
747151
def transform(self, X):
        """"""
        if not self.is_fit:
            raise ValueError("The scaler has not been fit yet.")
        return (X-self.mean) / (self.std + 10e-7)
536117
@Override
  public MeanVarianceMinMax put(double[] vals) {
    final int l = vals.length;
    if(l < 2) {
      if(l == 1) {
        put(vals[0]);
      }
      return this;
    }
    // First pass:
    double s1 = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i];
      s1 += v;
      min = v < min ? v : min;
      max = v > max ? v : max;
    }
    final double om1 = s1 / l;
    // Second pass:
    double om2 = 0., err = 0.;
    for(int i = 0; i < l; i++) {
      final double v = vals[i] - om1;
      om2 += v * v;
      err += v;
    }
    s1 += err;
    om2 += err / l;
    if(n <= 0) {
      n = l;
      sum = s1;
      m2 = om2;
      return this;
    }
    final double tmp = n * s1 - sum * l;
    final double oldn = n; // tmp copy
    n += l;
    sum += s1 + err;
    m2 += om2 + tmp * tmp / (l * n * oldn);
    return this;
  }
425156
public static double Kurtosis(int[] values){
        double mean = Mean(values);
        double std = StdDev(values, mean);
        return Kurtosis(values, mean, std);
    }
424693
private Double scale(Double value, Double maxAbsolute) {
        if(maxAbsolute.equals(0.0)) {
            return Math.signum(value);
        }
        else {
            return value/maxAbsolute;
        }
    }
1080299
private ValueUnitWrapper normalizeSpecialCases(double value, String unit)
            throws UnknownUnitException {
        if (unit.equals("mol/dm3")) {
            return new ValueUnitWrapper(value, MOLAR_NORMALIZED_UNIT);
        } else {
            throw new UnknownUnitException(unit);
        }
    }
981624
def normalizeKerningValue(value):
    
    if not isinstance(value, (int, float)):
        raise TypeError("Kerning value must be a int or a float, not %s."
                        % type(value).__name__)
    return value
1337454
static double clampMetricValue(double value) {
        // Leave as is and let the SDK reject it
        if (Double.isNaN(value)) {
            return value;
        }
        double magnitude = Math.abs(value);
        if (magnitude == 0) {
            // Leave zero as zero
            return 0;
        }
        // Non-zero magnitude, clamp to allowed range
        double clampedMag = Math.min(Math.max(magnitude, MINIMUM_ALLOWED_VALUE), MAXIMUM_ALLOWED_VALUE);
        return Math.copySign(clampedMag, value);
    }
178538
def normalize(x):
    ''''''
    x = x.astype(float)
    x -= x.mean()
    return x / float(x.std())
553487
public static double scaleValue(double value, int decimals) {
    BigDecimal bd = BigDecimal.valueOf(value);
    return bd.setScale(decimals, RoundingMode.HALF_UP).doubleValue();
  }
980315
private void standardize(double[] values) {
        double mean = calculateMean(values);
        double stdDev = calculateStandardDeviation(values, mean);

        /*
         * If standard deviation is 0, all values of the metric are
         * identical. Return vector of 0s.
         */
        if (stdDev == 0.0) {
            for (int i = 0; i < values.length; i++) {
                values[i] = 0.0;
            }
            return;
        };

        for (int i = 0; i < values.length; i++) {
            double standardizedValue = (values[i] - mean) / stdDev;
            values[i] = standardizedValue;
        }
    }
77790
def create(mean, std, mode='x', tags=None):
    
    return Normalize(mean=mean, std=std, mode=mode, tags=tags)
190198
function SNV(data) {
    var mean = Stat.mean(data);
    var std = Stat.standardDeviation(data);
    var result = data.slice();
    for (var i = 0; i < data.length; i++) {
        result[i] = (result[i] - mean) / std;
    }
    return result;
}
1337970
public SFSDataWrapper transform(Object value) {
        if(value == null)
            return transformNullValue(value);
        return transformNotNullValue(value);
    }