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

voidnormalizeAndInvertValues(double[] values, double maxValue, double minValue)
normalize And Invert Values
for (int i = 0; i < values.length; i++) {
    values[i] = 1 - (values[i] - minValue) / (maxValue - minValue);
double[]normalizeArray(double[] array)
normalize Array
int length = array.length;
double sum = 0;
for (double item : array) {
    sum += item;
double[] normalizedArray = new double[length];
for (int i = 0; i < length; i++) {
    normalizedArray[i] = array[i] / sum * 100;
...
double[]normalizeArray(double[] hist)
normalize Array
double sum = 0.0;
for (int i = 0; i < hist.length; i++) {
    sum += hist[i];
if (sum > 0.0d) {
    for (int i = 0; i < hist.length; i++) {
        hist[i] = hist[i] / sum;
return hist;
String[]normalizeArray(String[] raw, int expectedSize)
normalize Array
String[] normalized = new String[expectedSize];
Arrays.fill(normalized, "");
for (int i = 0; i < normalized.length; i++) {
    if (i < raw.length && raw[i] != null && !raw[i].isEmpty()) {
        normalized[i] = raw[i];
return normalized;
...
String[][]normalizeArrays(int normalizeToLength, String[]... arraysToNormalize)
Normalize String array lengths for synchronization of arrays within steps
if (arraysToNormalize == null) {
    return null;
int arraysToProcess = arraysToNormalize.length;
String[][] rtn = new String[arraysToProcess][];
for (int i = 0; i < arraysToNormalize.length; i++) {
    String[] nextArray = arraysToNormalize[i];
    if (nextArray != null) {
...
StringnormalizeCharacterData(char[] ch, int start, int length)
Used to process the characters found between two XML elements, this method removes any leading and trailing white space, including newlines.
StringBuffer buf = new StringBuffer();
normalizeCharacterData(ch, start, length, buf);
return buf.toString();
voidnormalizeComplexVectorsToUnitVectors(float[] complex)
normalize Complex Vectors To Unit Vectors
int wComplex = complex.length / 2;
double length;
for (int pos = 0; pos < wComplex; pos++) {
    length = Math.sqrt(Math.pow(complex[pos * 2], 2) + Math.pow(complex[pos * 2 + 1], 2));
    if (length > 1E-5) {
        complex[pos * 2 + 1] /= length;
        complex[pos * 2] /= length;
    } else {
...
voidnormalizeComponentsOverwrite(float[][][][] in)
normalize Components Overwrite
int nx = in.length;
int ny = in[0].length;
int nz = in[0][0].length;
int nc = in[0][0][0].length;
float lensqr = -1;
for (int x = 0; x < nx; x++)
    for (int y = 0; y < ny; y++)
        for (int z = 0; z < nz; z++) {
...
int[][]normalizeContingencyTable(final int[][] table)
Normalize the table so that the entries are not too large.
final int sum = table[0][0] + table[0][1] + table[1][0] + table[1][1];
if (sum <= TARGET_TABLE_SIZE * 2)
    return table;
final double normalizationFactor = (double) sum / TARGET_TABLE_SIZE;
final int[][] normalized = new int[ARRAY_DIM][ARRAY_DIM];
for (int i = 0; i < ARRAY_DIM; i++) {
    for (int j = 0; j < ARRAY_DIM; j++)
        normalized[i][j] = (int) (table[i][j] / normalizationFactor);
...
float[]normalizeCoordsSum(float[] vector, float newSum)
normalize Coords Sum
float sum = 0;
for (int i = 0; i < vector.length; i++) {
    sum += vector[i];
for (int i = 0; i < vector.length; i++) {
    vector[i] /= sum * newSum;
return vector;
...