Java tutorial
//package com.java2s; import java.util.*; import static java.lang.Math.*; public class Main { /** * * @param pressingLength length of pause between clicks * @param mathExpectation mathExpectation values list * @return dispersion values list */ public static List<Double> dispersion(Map<String, Long> pressingLength, List<Double> mathExpectation) { int N = pressingLength.size() - 1; //dispersion int i = 0; ArrayList<Double> dispersion = new ArrayList<Double>(); for (String key : pressingLength.keySet()) { double x; double s = 0.0; for (String k : pressingLength.keySet()) { if (!k.equals(key)) { x = pressingLength.get(k) - mathExpectation.get(i); s += x * x; } } dispersion.add(sqrt(s / (N - 1))); i++; } return dispersion; } }