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[]normalizeVoxelDimensions(final double[] voxelDimensions)
normalize Voxel Dimensions
final double[] normalizedVoxelDimensions = new double[voxelDimensions.length];
double voxelDimensionsMinValue = Double.MAX_VALUE;
for (int d = 0; d < normalizedVoxelDimensions.length; d++)
    voxelDimensionsMinValue = Math.min(voxelDimensions[d], voxelDimensionsMinValue);
for (int d = 0; d < normalizedVoxelDimensions.length; d++)
    normalizedVoxelDimensions[d] = voxelDimensions[d] / voxelDimensionsMinValue;
return normalizedVoxelDimensions;
voidnormalizeWith(double[] arr, double v)
normalize With
for (int i = 0; i < arr.length; i++) {
    arr[i] /= v;
double[]normalizeZscore(double[] x)
Calculates x_i = (x_i - mean(x)) / std(x) This function can deal with NaNs
double mn = mean(x, 0);
double sd = standardDeviation(x, 0);
for (int i = 0; i < x.length; i++)
    if (!Double.isNaN(x[i]))
        x[i] = (x[i] - mn) / sd;
return x;
voidnormBySortedPointersInverse(double[] d, int[] pointers)
Example: normBySortedPointers data in arbitrary range, run neuralnet on it, then normBySortedPointersInverse to put neuralnet's output back into that same spread of data but a different permutation of it.
double[] inverse = new double[d.length];
for (int i = 0; i < d.length; i++) {
    inverse[i] = d[pointers[i]];
System.arraycopy(inverse, 0, d, 0, d.length);
double[]normData(double[] data)
\ingroup isti_utils_public_functions \brief Demeans data in-place.
double[] ret = new double[data.length];
double sumData = 0.0;
for (int i = 0; i < data.length; i++)
    sumData += data[i];
final double meanData = sumData / data.length;
for (int i = 0; i < data.length; i++)
    ret[i] = data[i] - meanData;
return ret;
...
doublenormII(double[] b)
Second norm of vector: sum(abs(vector))
double result = 0;
for (int i = 0; i < b.length; i++) {
    result += Math.abs(b[i]);
return result;
voidnormLat(double[] latLng)
norm Lat
if (latLng[0] > DEG_90_AS_RADS) {
    latLng[0] = DEG_90_AS_RADS - (latLng[0] - DEG_90_AS_RADS);
    if (latLng[1] < 0) {
        latLng[1] = latLng[1] + DEG_180_AS_RADS;
    } else {
        latLng[1] = latLng[1] - DEG_180_AS_RADS;
} else if (latLng[0] < -DEG_90_AS_RADS) {
...
voidnormLng(double[] latLng)
Returns a normalized Lng rectangle shape for the bounding box
if (latLng[1] > DEG_180_AS_RADS) {
    latLng[1] = -1.0 * (DEG_180_AS_RADS - (latLng[1] - DEG_180_AS_RADS));
} else if (latLng[1] < -DEG_180_AS_RADS) {
    latLng[1] = (latLng[1] + DEG_180_AS_RADS) + DEG_180_AS_RADS;
floatnormOf(float[] vector)
norm Of
float sum = 0f;
for (int i = 0; i < vector.length; i++) {
    sum += vector[i] * vector[i];
return (float) Math.sqrt(sum);
floatnormSquareVec2(final float[] vec)
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
return vec[0] * vec[0] + vec[1] * vec[1];