Java Array Normalize normalize(double[] descriptor)

Here you can find the source of normalize(double[] descriptor)

Description

Method that normalizes the descriptor passed as a parameter Limits for this method are: --- Min: 0 --- Max: 200

License

Open Source License

Parameter

Parameter Description
descriptor a parameter

Declaration

public static double[] normalize(double[] descriptor) 

Method Source Code

//package com.java2s;
/*/* w ww  .  jav a 2  s .c  om*/
* The GPLv3 licence :
* -----------------
* Copyright (c) 2009 Ricardo Dias
*
* This file is part of MuVis.
*
* MuVis is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MuVis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MuVis.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    /**
     * Method that normalizes the descriptor passed as a parameter
     * Limits for this method are:
     * --- Min: 0
     * --- Max: 200
     * @param descriptor
     * @return
     */
    public static double[] normalize(double[] descriptor) {

        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 num = minNorm + (parc1 / parc2) * (maxNorm - minNorm);

            //update the new position
            normalizedDescriptor[i] = num;
        }

        return normalizedDescriptor;
    }
}

Related

  1. normalize(double[] array)
  2. normalize(double[] bins)
  3. normalize(double[] d)
  4. normalize(double[] data)
  5. normalize(double[] data, double floor)
  6. normalize(double[] doubleArray)
  7. normalize(double[] doubles)
  8. normalize(double[] doubles)
  9. normalize(double[] doubles)