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[]normalize(double[] ar)
Returns a new array which has the numbers in the input array L1-normalized.
double[] ar2 = new double[ar.length];
double total = 0.0;
for (double d : ar) {
    total += d;
for (int i = 0; i < ar.length; i++) {
    ar2[i] = ar[i] / total;
return ar2;
voidnormalize(double[] array)
Normalizes the given array such that the sum of its elements equals 1.
double sum = 0;
for (double d : array) {
    if (d < 0)
        throw new IllegalArgumentException("Elements cannot be negative.");
    sum += d;
if (sum == 0) {
    double value = 1.0 / array.length;
...
double[]normalize(double[] array)
normalize
double sum = sum(array);
for (int i = 0; i < array.length; i++) {
    array[i] = array[i] / sum;
return array;
voidnormalize(double[] array)
normalize
double s = 0;
double as = 0;
for (int i = 0; i < array.length; ++i) {
    s += array[i];
    as += Math.abs(array[i]);
if (as > 0) {
    for (int i = 0; i < array.length; ++i) {
...
double[]normalize(double[] bins)
Scales bins to 0-1 scale.
double sum = 0;
for (int i = 0; i < bins.length; i++) {
    sum += bins[i];
double[] normbins = new double[bins.length];
for (int i = 0; i < bins.length; i++) {
    if (sum == 0)
        normbins[i] = 0;
...
double[]normalize(double[] d)
Normalizes d .
double[] dPrime = new double[d.length];
double sum = 0.0;
for (int i = 0; i < d.length; i++) {
    sum += d[i];
for (int i = 0; i < dPrime.length; i++) {
    dPrime[i] = d[i] / sum;
return dPrime;
double[]normalize(double[] data)
normalize histogram, sum of all fractional counts = 1.
double[] norm = new double[data.length];
double total_sum = 0.0;
for (int i = 0; i < data.length; ++i) {
    total_sum += data[i];
for (int i = 0; i < data.length; ++i) {
    norm[i] = data[i] / total_sum;
return norm;
voidnormalize(double[] data, double floor)
normalize
double sum = 0;
for (double x : data)
    sum += x;
for (int i = 0; i < data.length; i++) {
    if (sum != 0)
        data[i] /= sum;
    if (data[i] < floor)
        data[i] = floor;
...
double[]normalize(double[] descriptor)
Method that normalizes the descriptor passed as a parameter Limits for this method are: --- Min: 0 --- Max: 200
int max = 200;
int min = 0;
int minNorm = 0;
int maxNorm = 1;
double[] normalizedDescriptor = new double[descriptor.length];
for (int i = 0; i < descriptor.length; i++) {
    double parc1 = descriptor[i] - min;
    double parc2 = max - min;
...
double[]normalize(double[] doubleArray)
normalize
double arraySum = sum(doubleArray);
double[] arrayNormalized = new double[doubleArray.length];
for (int i = 0; i < doubleArray.length; i++) {
    arrayNormalized[i] = doubleArray[i] / arraySum;
return arrayNormalized;