Here you can find the source of variance(List
public static double variance(List<Integer> data)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.List; public class Main { public static double variance(List<Integer> data) { int n = data.size(); double sum = 0; double avg = sum(data) / ((double) n); for (int d : data) { sum += (d - avg) * (d - avg); }//from ww w .ja v a 2 s . com return sum / n; } public static int sum(Collection<Integer> data) { int sum = 0; for (int d : data) { sum += d; } return sum; } }