Java Variance variance(double[] a, int from, int to)

Here you can find the source of variance(double[] a, int from, int to)

Description

variance

License

Open Source License

Declaration

public static double variance(double[] a, int from, int to) 

Method Source Code

//package com.java2s;

public class Main {
    public static double variance(double[] a, int from, int to) {
        double mean = mean(a, from, to);
        double result = 0.0;
        for (int i = from; i < to; i++) {
            double d = a[i] - mean;
            result += d * d;/*  w ww.j a v a2  s  .c o  m*/
        }
        return result / (to - from);
    }

    public static double mean(double[] a) {
        return mean(a, 0, a.length);
    }

    public static double mean(double[] a, int from, int to) {
        double mean = 0.0;
        for (int i = from; i < to; i++) {
            mean += a[i];
        }
        return mean / (to - from);
    }
}

Related

  1. variance(double... array)
  2. variance(double[] a)
  3. variance(double[] arr)
  4. variance(double[] arr)
  5. variance(double[] array)
  6. variance(double[] array)