Here you can find the source of variance(List
public static float variance(List<Float> values)
//package com.java2s; //License from project: LGPL import java.util.List; public class Main { public static float variance(List<Float> values) { float mean = mean(values); float variance = 0; for (float value : values) { variance += Math.pow(value - mean, 2); }// w w w . j a v a 2s .c om variance = variance / ((float) values.size()); return variance; } public static float variance(float[] values) { float mean = mean(values); float variance = 0; for (float value : values) { variance += Math.pow(value - mean, 2); } variance = variance / ((float) values.length - 1); return variance; } public static float mean(List<Float> values) { float mean = 0; for (float value : values) { mean += value; } mean = mean / (float) values.size(); return mean; } public static float mean(float[] values) { float mean = 0; for (float value : values) { mean += value; } mean = mean / (float) values.length; return mean; } }