Java Array Normalize normalize(double[][] result)

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

Description

normalize

License

Open Source License

Declaration

public static void normalize(double[][] result) 

Method Source Code

//package com.java2s;
/* ***** BEGIN LICENSE BLOCK *****
 *
 * Copyright (c) 2005-2007 Universidade de Sao Paulo, Sao Carlos/SP, Brazil.
 * All Rights Reserved.// w w w.  jav  a2s .  c  om
 *
 * This file is part of Projection Explorer (PEx).
 *
 * How to cite this work:
 *  
@inproceedings{paulovich2007pex,
author = {Fernando V. Paulovich and Maria Cristina F. Oliveira and Rosane 
Minghim},
title = {The Projection Explorer: A Flexible Tool for Projection-based 
Multidimensional Visualization},
booktitle = {SIBGRAPI '07: Proceedings of the XX Brazilian Symposium on 
Computer Graphics and Image Processing (SIBGRAPI 2007)},
year = {2007},
isbn = {0-7695-2996-8},
pages = {27--34},
doi = {http://dx.doi.org/10.1109/SIBGRAPI.2007.39},
publisher = {IEEE Computer Society},
address = {Washington, DC, USA},
}
 *  
 * PEx 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.
 *
 * PEx 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.
 *
 * This code was developed by members of Computer Graphics and Image
 * Processing Group (http://www.lcad.icmc.usp.br) at Instituto de Ciencias
 * Matematicas e de Computacao - ICMC - (http://www.icmc.usp.br) of 
 * Universidade de Sao Paulo, Sao Carlos/SP, Brazil. The initial developer 
 * of the original code is Fernando Vieira Paulovich <fpaulovich@gmail.com>, 
 * Roberto Pinho <robertopinho@yahoo.com.br>.
 *
 * Contributor(s): Rosane Minghim <rminghim@icmc.usp.br>
 *
 * You should have received a copy of the GNU General Public License along 
 * with PEx. If not, see <http://www.gnu.org/licenses/>.
 *
 * ***** END LICENSE BLOCK ***** */

public class Main {
    public static void normalize(double[][] result) {
        int lvdimensions = result[0].length;
        int lvinstances = result.length;

        //for normalization
        double[] lvlowrange = new double[lvdimensions];
        double[] lvhighrange = new double[lvdimensions];

        //for each instance
        for (int lvins = 0; lvins < lvinstances; lvins++) {
            //for each attribute
            for (int lvfield = 0; lvfield < lvdimensions; lvfield++) {
                //if it is the first instance then assign the first value
                if (lvins == 0) {
                    lvlowrange[lvfield] = result[lvins][lvfield];
                    lvhighrange[lvfield] = result[lvins][lvfield];
                } //otherwise compare
                else {
                    lvlowrange[lvfield] = lvlowrange[lvfield] > result[lvins][lvfield] ? result[lvins][lvfield]
                            : lvlowrange[lvfield];
                    lvhighrange[lvfield] = lvhighrange[lvfield] < result[lvins][lvfield] ? result[lvins][lvfield]
                            : lvhighrange[lvfield];
                }
            }
        }

        //for each instance
        for (int lvins = 0; lvins < lvinstances; lvins++) {
            //for each attribute
            for (int lvfield = 0; lvfield < lvdimensions; lvfield++) {
                if ((lvhighrange[lvfield] - lvlowrange[lvfield]) > 0.0) {
                    result[lvins][lvfield] = (result[lvins][lvfield] - lvlowrange[lvfield])
                            / (lvhighrange[lvfield] - lvlowrange[lvfield]);
                } else {
                    result[lvins][lvfield] = 0;
                }
            }
        }
    }
}

Related

  1. normalize(double[] weights)
  2. normalize(double[] weights)
  3. normalize(double[] x)
  4. normalize(double[] xs)
  5. normalize(double[][] matrix, double lower, double upper)
  6. normalize(double[][] X)
  7. normalize(final byte[] input, final int bit)
  8. normalize(final double[] a)
  9. normalize(final double[] doubles)