Java tutorial
//package com.java2s; import java.util.*; import static java.lang.Math.*; public class Main { /** * @return clear map of pressing time values, discard wrong values */ public static Map<String, Long> discardingOutliers(Map<String, Long> pressingLength, List<Double> dispersion, List<Double> mathExpectation) { Map<String, Long> clear = new HashMap<String, Long>(); int i = 0; for (String key : pressingLength.keySet()) { if ((pressingLength.get(key) >= (mathExpectation.get(i) - 3 * sqrt(dispersion.get(i)))) && (pressingLength.get(key) <= (mathExpectation.get(i) + 3 * sqrt(dispersion.get(i++))))) { clear.put(key, pressingLength.get(key)); } } return clear; } }