Java Variance variance(double[] array)

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

Description

variance

License

Open Source License

Declaration

public static double variance(double[] array) 

Method Source Code

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

public class Main {
    public static double variance(double[] array) {
        double variance = 0;

        double mean = 0;

        for (int i = 0; i < array.length; i++) {
            mean += array[i];/*from   www .jav a  2s  .  com*/
        }

        mean /= array.length;

        for (int i = 0; i < array.length; i++) {
            variance += Math.pow((array[i] - mean), 2);
        }

        variance /= array.length;

        return variance;
    }
}

Related

  1. variance(double... array)
  2. variance(double[] a)
  3. variance(double[] a, int from, int to)
  4. variance(double[] arr)
  5. variance(double[] arr)
  6. variance(double[] array)
  7. variance(double[] d)
  8. Variance(double[] in, double mean)
  9. variance(double[] population)