Here you can find the source of normalize(float[] data)
Parameter | Description |
---|---|
data | the data to normalize |
public static void normalize(float[] data)
//package com.java2s; /*/* w w w .j ava 2 s .c om*/ * Copyright 1999-2002 Carnegie Mellon University. * Portions Copyright 2002 Sun Microsystems, Inc. * Portions Copyright 2002 Mitsubishi Electric Research Laboratories. * All Rights Reserved. Use is subject to license terms. * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. * */ public class Main { /** * Normalize the given data. * * @param data the data to normalize */ public static void normalize(float[] data) { float sum = 0; for (float val : data) { sum += val; } if (sum != 0.0f) { for (int i = 0; i < data.length; i++) { data[i] = data[i] / sum; } } } }