Java Array Normalize normalizeForce(double[] data)

Here you can find the source of normalizeForce(double[] data)

Description

normalize Force

License

Apache License

Declaration

public static boolean normalizeForce(double[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static boolean normalizeForce(double[] data) {
        double sum = 0;
        for (double x : data)
            sum += x;//w  w w  . j  a  va  2 s .c  o  m
        if (sum == 0) {
            for (int i = 0; i < data.length; i++)
                data[i] = 1.0 / data.length;
            return false;
        } else {
            for (int i = 0; i < data.length; i++)
                data[i] /= sum;
            return true;
        }
    }
}

Related

  1. normalizeContingencyTable(final int[][] table)
  2. normalizeCoordsSum(float[] vector, float newSum)
  3. normalizedBySum(double[] values)
  4. normalizedTermMu(double ui, double[] uis)
  5. normalizeFloatArray(float[] buffer, float peak, float target)
  6. normalizeFromLog10(double[] array)
  7. normalizeFromLog10(double[] array, boolean takeLog10OfOutput)
  8. normalizeFromLog10(final double[] array, final boolean takeLog10OfOutput, final boolean keepInLogSpace)
  9. normalizeFromRealSpace(final double[] array)