Java Utililty Methods Array Normalize

List of utility methods to do Array Normalize

Description

The list of methods to do Array Normalize are organized into topic(s).

Method

double[]normalizedBySum(double[] values)
normalized By Sum
double[] normedValues = new double[values.length];
double sum = 0.0;
for (int k = 0; k < values.length; k++) {
    sum += values[k];
for (int k = 0; k < values.length; k++) {
    normedValues[k] = values[k] / sum;
return normedValues;
doublenormalizedTermMu(double ui, double[] uis)
normalized Term Mu
double max = getMax(uis);
return ui / max;
float[]normalizeFloatArray(float[] buffer, float peak, float target)
Normalizes the values in the given array to the new absolute target value.
float invPeak = target / peak;
for (int i = 0; i < buffer.length; i++) {
    buffer[i] *= invPeak;
return buffer;
booleannormalizeForce(double[] data)
normalize Force
double sum = 0;
for (double x : data)
    sum += x;
if (sum == 0) {
    for (int i = 0; i < data.length; i++)
        data[i] = 1.0 / data.length;
    return false;
} else {
...
double[]normalizeFromLog10(double[] array)
normalizes the log10-based array.
return normalizeFromLog10(array, false);
double[]normalizeFromLog10(double[] array, boolean takeLog10OfOutput)
normalizes the log10-based array.
return normalizeFromLog10(array, takeLog10OfOutput, false);
double[]normalizeFromLog10(final double[] array, final boolean takeLog10OfOutput, final boolean keepInLogSpace)
See #normalizeFromLog10 but with the additional option to use an approximation that keeps the calculation always in log-space
double maxValue = arrayMax(array);
if (keepInLogSpace) {
    for (int i = 0; i < array.length; i++) {
        array[i] -= maxValue;
    return array;
double[] normalized = new double[array.length];
...
double[]normalizeFromRealSpace(final double[] array)
normalizes the real-space probability array.
if (array.length == 0)
    return array;
final double sum = sum(array);
final double[] normalized = new double[array.length];
if (sum < 0.0)
    throw new IllegalArgumentException("Values in probability array sum to a negative number " + sum);
for (int i = 0; i < array.length; i++) {
    normalized[i] = array[i] / sum;
...
voidnormalizeHeightMap(float heightMap[])
normalize Height Map
int mapArea = heightMap.length;
float minHeight = heightMap[0], maxHeight = heightMap[0];
for (int i = 1; i < mapArea; i++) {
    if (heightMap[i] < minHeight)
        minHeight = heightMap[i];
    if (heightMap[i] > maxHeight)
        maxHeight = heightMap[i];
float scaleFactor = maxHeight - minHeight;
for (int i = 0; i < mapArea; i++) {
    heightMap[i] = (heightMap[i] - minHeight) / scaleFactor;
float[]normalizeHeightMapCopy(float heightMap[])
normalize Height Map Copy
float tmpHM[] = new float[heightMap.length];
System.arraycopy(heightMap, 0, tmpHM, 0, heightMap.length);
normalizeHeightMap(tmpHM);
return tmpHM;