Java Array Normalize normalize(double[] values)

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

Description

normalize

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] normalize(double[] values) {
        double sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += (values[i] * values[i]);
        }/*from  ww  w.j  a v  a2 s  . c  o m*/
        sum = Math.sqrt(sum);
        double[] newValues = new double[values.length];
        for (int i = 0; i < newValues.length; i++) {
            newValues[i] = values[i] / sum;
        }

        return newValues;
    }
}

Related

  1. normalize(double[] points)
  2. normalize(double[] state)
  3. normalize(double[] v)
  4. normalize(double[] v)
  5. normalize(double[] vals)
  6. normalize(double[] vector)
  7. normalize(double[] vector)
  8. normalize(double[] w)
  9. normalize(double[] weights)