Java Array Normalize norm_variance(double[] array)

Here you can find the source of norm_variance(double[] array)

Description

norvariance

License

Open Source License

Declaration

public static double norm_variance(double[] array) 

Method Source Code

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

public class Main {
    public static double norm_variance(double[] array) {
        double sum = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];/* w  w  w . j ava 2 s .  c  o  m*/
        }
        double[] temp = new double[array.length];
        for (int i = 0; i < array.length; i++) {
            temp[i] = array[i] / sum;
        }
        double avg = 1.0 / array.length;
        double var = 0;
        for (int i = 0; i < temp.length; i++) {
            var += (temp[i] - avg) * (temp[i] - avg);
        }
        return var;
    }
}

Related

  1. norm(int D, double vec[])
  2. norm2(double[] vec)
  3. norm2(double[] vector)
  4. norm2(double[] x)
  5. norm2DoubleArray(double[] v)
  6. norm_vec(double[] vec)
  7. normal0(double[] p1, double[] p2, double[] p3)
  8. normalCentralMoment(boolean[][] img, int p, int q)
  9. normalDist(double[] features, double[] avg, double[][] cov)