Here you can find the source of variance(double[] a, int from, int to)
public static double variance(double[] a, int from, int to)
//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); } }